#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 atoi(char const *);
int strcmp(char const *, char *);
int tolower(int);
int booleanValue(char *zArg) {
  int val;
  int tmp;
  int j;
  int tmp___0;
  int tmp___1;
  int tmp___2;
  char const *__cil_tmp8;
  char *__cil_tmp9;
  char *__cil_tmp10;
  char __cil_tmp11;
  int __cil_tmp12;
  char *__cil_tmp13;
  char const *__cil_tmp14;
  char const *__cil_tmp15;
  {
    {
      __cil_tmp8 = (char const *)zArg;
      tmp = atoi(__cil_tmp8);
      val = tmp;
      j = 0;
    }
    {
      while (1) {
      while_35_continue:;
        {
          __cil_tmp9 = zArg + j;
          if (*__cil_tmp9) {
          } else {
            goto while_35_break;
          }
        }
        {
          __cil_tmp10 = zArg + j;
          __cil_tmp11 = *__cil_tmp10;
          __cil_tmp12 = (int)__cil_tmp11;
          tmp___0 = tolower(__cil_tmp12);
          __cil_tmp13 = zArg + j;
          *__cil_tmp13 = (char)tmp___0;
          j = j + 1;
        }
      }
    while_35_break:;
    }
    {
      __cil_tmp14 = (char const *)zArg;
      tmp___2 = strcmp(__cil_tmp14, "on");
    }
    if (tmp___2 == 0) {
      val = 1;
    } else {
      {
        __cil_tmp15 = (char const *)zArg;
        tmp___1 = strcmp(__cil_tmp15, "yes");
      }
      if (tmp___1 == 0) {
        val = 1;
      } else {
      }
    }
    return (val);
  }
}


x86 assembly (clang, -O0):
<booleanValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    1162 <booleanValue+0x32>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <booleanValue+0x53>
jmp    1188 <booleanValue+0x58>
jmp    11da <booleanValue+0xaa>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x39(%rbp)
movsbl -0x39(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
call   1040 <tolower@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <booleanValue+0x2d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    120b <booleanValue+0xdb>
movl   $0x1,-0xc(%rbp)
jmp    1246 <booleanValue+0x116>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    123c <booleanValue+0x10c>
movl   $0x1,-0xc(%rbp)
jmp    1241 <booleanValue+0x111>
jmp    1241 <booleanValue+0x111>
jmp    1246 <booleanValue+0x116>
mov    -0xc(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<booleanValue>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    (%rbx),%al
test   %al,%al
je     1167 <booleanValue+0x37>
lea    0x1(%rbx),%rbp
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbp)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1150 <booleanValue+0x20>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1196 <booleanValue+0x66>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
mov    $0x1,%eax
cmove  %eax,%r14d
jmp    119c <booleanValue+0x6c>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"yes\00"
define i32 @booleanValue(i8* nocapture %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %12, %5 ], [ 0, %1 ]
%7 = phi i8 [ %14, %5 ], [ %3, %1 ]
%8 = phi i8* [ %13, %5 ], [ %0, %1 ]
%9 = sext i8 %7 to i32
%10 = tail call i32 @tolower(i32 %9)
%11 = trunc i32 %10 to i8
store i8 %11, i8* %8
%12 = add nuw nsw i64 %6, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %1
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 1, i32 %2
br label %23
23: ; preds = %19, %16
%24 = phi i32 [ 1, %16 ], [ %22, %19 ]
ret i32 %24
}