#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 */
scalar_t__ strcmp(char const *, char *);
int OnOffReset(const char *p, int *the_flag, int initial_flag_value) {
  if (strcmp(p, "on") == 0)
    *the_flag = 1;
  else if (strcmp(p, "off") == 0)
    *the_flag = 0;
  else if (strcmp(p, "reset") == 0)
    *the_flag = initial_flag_value;
  else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<OnOffReset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    114c <OnOffReset+0x3c>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11b3 <OnOffReset+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1175 <OnOffReset+0x65>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11ae <OnOffReset+0x9e>
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119d <OnOffReset+0x8d>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11a9 <OnOffReset+0x99>
movl   $0x0,-0x4(%rbp)
jmp    11ba <OnOffReset+0xaa>
jmp    11ae <OnOffReset+0x9e>
jmp    11b3 <OnOffReset+0xa3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OnOffReset>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xedc(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%edx
test   %rax,%rax
je     1167 <OnOffReset+0x57>
lea    0xec9(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1165 <OnOffReset+0x55>
lea    0xeb9(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    %r14d,%edx
test   %rcx,%rcx
jne    116e <OnOffReset+0x5e>
jmp    1167 <OnOffReset+0x57>
xor    %edx,%edx
mov    %edx,(%rbx)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [6 x i8] c"reset\00"
define i32 @OnOffReset(i8* %0, i32* nocapture writeonly %1, i32 %2) {
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9, %6, %3
%13 = phi i32 [ 1, %3 ], [ 0, %6 ], [ %2, %9 ]
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ 0, %9 ], [ 1, %12 ]
ret i32 %15
}