#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 sscanf(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int scan_mode(char *attr_str, long *majorp, long *minorp) {
  int count;
  char buf[18];
  if ((count = sscanf(attr_str, "%17s", buf)) != 1)
    return -1;
  if (!strcmp(buf, "dedicated_process")) {
    *majorp = 0x1;
    count = 0;
  } else if (!strcmp(buf, "afu_directed")) {
    *majorp = 0x2;
    count = 0;
  }
  return (count == 0);
}


x86 assembly (clang, -O0):
<scan_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xebd(%rip),%rsi
call   1040 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x1,%eax
je     1160 <scan_mode+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cf <scan_mode+0xaf>
lea    -0x40(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1190 <scan_mode+0x70>
mov    -0x18(%rbp),%rax
movq   $0x1,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    11c0 <scan_mode+0xa0>
lea    -0x40(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11bb <scan_mode+0x9b>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    11c0 <scan_mode+0xa0>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_mode>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0xf01(%rip),%rsi
mov    %rsp,%rdx
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    1198 <scan_mode+0x88>
movdqa (%rsp),%xmm0
movzwl 0x10(%rsp),%eax
movd   %eax,%xmm1
pcmpeqb 0xeb7(%rip),%xmm0
pcmpeqb 0xebf(%rip),%xmm1
pand   %xmm0,%xmm1
pmovmskb %xmm1,%eax
cmp    $0xffff,%eax
je     118b <scan_mode+0x7b>
movabs $0x657269645f756661,%rcx
69 72 65
xor    (%rsp),%rcx
movabs $0x64657463657269,%rdx
xor    0x5(%rsp),%rdx
xor    %eax,%eax
or     %rcx,%rdx
jne    1198 <scan_mode+0x88>
mov    $0x2,%eax
jmp    1190 <scan_mode+0x80>
mov    $0x1,%eax
mov    %rax,(%rbx)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%17s\00"
@.str.1 = [18 x i8] c"dedicated_process\00"
@.str.2 = [13 x i8] c"afu_directed\00"
define i32 @scan_mode(i8* %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i32
%9 = alloca [18 x i8]
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%12 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 %12, i32* %8
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %32
15: ; preds = %3
%16 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = load i64*, i64** %6
store i64 1, i64* %20
store i32 0, i32* %8
br label %28
21: ; preds = %15
%22 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = load i64*, i64** %6
store i64 2, i64* %26
store i32 0, i32* %8
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27, %19
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
store i32 %31, i32* %4
br label %32
32: ; preds = %28, %14
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c"%17s\00"
@.str.1 = [18 x i8] c"dedicated_process\00"
@.str.2 = [13 x i8] c"afu_directed\00"
define i32 @scan_mode(i8* nocapture %0, i64* nocapture writeonly %1, i64* nocapture readnone %2) {
%4 = alloca [18 x i8]
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = call i32 @bcmp(i8* dereferenceable(18) %5, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 18)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = call i32 @bcmp(i8* dereferenceable(13) %5, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 13)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %8
%15 = phi i64 [ 1, %8 ], [ 2, %11 ]
store i64 %15, i64* %1
br label %16
16: ; preds = %14, %11, %3
%17 = phi i32 [ -1, %3 ], [ 0, %11 ], [ 1, %14 ]
ret i32 %17
}