#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char const *, int);
int sscanf(char const *, char *, unsigned long *, unsigned long *);
char *strchr(char const *, char);
int parseDispCardInfo(const char *dispCard, char *szName, char *szDriver,
                      unsigned long *VersionMS, unsigned long *VersionLS) {
  const char *pbuf = dispCard;
  const char *ptr = pbuf;
  ;
  pbuf = strchr(ptr, ',');
  if (!pbuf) {
    ;
    return 2;
  }
  memcpy(szName, ptr, (pbuf - ptr));
  szName[(pbuf - ptr)] = '\0';
  ptr = ++pbuf;
  pbuf = strchr(ptr, ',');
  if (!pbuf) {
    ;
    return 2;
  }
  memcpy(szDriver, ptr, (pbuf - ptr));
  szDriver[(pbuf - ptr)] = '\0';
  if (sscanf(pbuf, ",%lx,%lx", VersionMS, VersionLS) != 2) {
    ;
    return 2;
  };
  return 0;
}


x86 assembly (clang, -O0):
<parseDispCardInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1185 <parseDispCardInfo+0x55>
movl   $0x2,-0x4(%rbp)
jmp    124c <parseDispCardInfo+0x11c>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11eb <parseDispCardInfo+0xbb>
movl   $0x2,-0x4(%rbp)
jmp    124c <parseDispCardInfo+0x11c>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xdd5(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1245 <parseDispCardInfo+0x115>
movl   $0x2,-0x4(%rbp)
jmp    124c <parseDispCardInfo+0x11c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDispCardInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,0x10(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11d9 <parseDispCardInfo+0xa9>
mov    %rax,%r15
mov    %rbx,0x8(%rsp)
mov    %rax,%rbx
sub    %r14,%rbx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movb   $0x0,0x0(%r13,%rbx,1)
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11d9 <parseDispCardInfo+0xa9>
mov    %rax,%r13
mov    %rax,%rbx
sub    %r15,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movb   $0x0,(%r12,%rbx,1)
lea    0xe44(%rip),%rsi
mov    %r13,%rdi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
call   1050 <sscanf@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
setne  %bpl
add    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c",%lx,%lx\00"
define i32 @parseDispCardInfo(i8* %0, i8* %1, i8* %2, i64* %3, i64* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64*
%11 = alloca i64*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i64* %3, i64** %10
store i64* %4, i64** %11
%14 = load i8*, i8** %7
store i8* %14, i8** %12
%15 = load i8*, i8** %12
store i8* %15, i8** %13
%16 = load i8*, i8** %13
%17 = call i8* @strchr(i8* %16, i8 signext 44)
store i8* %17, i8** %12
%18 = load i8*, i8** %12
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %5
store i32 2, i32* %6
br label %69
21: ; preds = %5
%22 = load i8*, i8** %8
%23 = load i8*, i8** %13
%24 = load i8*, i8** %12
%25 = load i8*, i8** %13
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = call i32 @memcpy(i8* %22, i8* %23, i32 %29)
%31 = load i8*, i8** %8
%32 = load i8*, i8** %12
%33 = load i8*, i8** %13
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = getelementptr inbounds i8, i8* %31, i64 %36
store i8 0, i8* %37
%38 = load i8*, i8** %12
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %12
store i8* %39, i8** %13
%40 = load i8*, i8** %13
%41 = call i8* @strchr(i8* %40, i8 signext 44)
store i8* %41, i8** %12
%42 = load i8*, i8** %12
%43 = icmp ne i8* %42, null
br i1 %43, label %45, label %44
44: ; preds = %21
store i32 2, i32* %6
br label %69
45: ; preds = %21
%46 = load i8*, i8** %9
%47 = load i8*, i8** %13
%48 = load i8*, i8** %12
%49 = load i8*, i8** %13
%50 = ptrtoint i8* %48 to i64
%51 = ptrtoint i8* %49 to i64
%52 = sub i64 %50, %51
%53 = trunc i64 %52 to i32
%54 = call i32 @memcpy(i8* %46, i8* %47, i32 %53)
%55 = load i8*, i8** %9
%56 = load i8*, i8** %12
%57 = load i8*, i8** %13
%58 = ptrtoint i8* %56 to i64
%59 = ptrtoint i8* %57 to i64
%60 = sub i64 %58, %59
%61 = getelementptr inbounds i8, i8* %55, i64 %60
store i8 0, i8* %61
%62 = load i8*, i8** %12
%63 = load i64*, i64** %10
%64 = load i64*, i64** %11
%65 = call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %63, i64* %64)
%66 = icmp ne i32 %65, 2
br i1 %66, label %67, label %68
67: ; preds = %45
store i32 2, i32* %6
br label %69
68: ; preds = %45
store i32 0, i32* %6
br label %69
69: ; preds = %68, %67, %44, %20
%70 = load i32, i32* %6
ret i32 %70
}

LLVM IR (-O2):
@.str = [9 x i8] c",%lx,%lx\00"
define i32 @parseDispCardInfo(i8* %0, i8* %1, i8* %2, i64* %3, i64* %4) {
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 44)
%7 = icmp eq i8* %6, null
br i1 %7, label %28, label %8
8: ; preds = %5
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %12)
%14 = getelementptr inbounds i8, i8* %1, i64 %11
store i8 0, i8* %14
%15 = getelementptr inbounds i8, i8* %6, i64 1
%16 = tail call i8* @strchr(i8* %15, i8 signext 44)
%17 = icmp eq i8* %16, null
br i1 %17, label %28, label %18
18: ; preds = %8
%19 = ptrtoint i8* %16 to i64
%20 = ptrtoint i8* %15 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
%23 = tail call i32 @memcpy(i8* %2, i8* %15, i32 %22)
%24 = getelementptr inbounds i8, i8* %2, i64 %21
store i8 0, i8* %24
%25 = tail call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %3, i64* %4)
%26 = icmp eq i32 %25, 2
%27 = select i1 %26, i32 0, i32 2
br label %28
28: ; preds = %18, %8, %5
%29 = phi i32 [ 2, %5 ], [ 2, %8 ], [ %27, %18 ]
ret i32 %29
}