#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*/ efindword(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int findonoff(int *ip) {
  char s[32];
  efindword(s);
  if (!strcmp(s, "on")) {
    *ip = 1;
    return 0;
  }
  if (!strcmp(s, "off")) {
    *ip = 0;
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<findonoff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <efindword@plt>
lea    -0x30(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1164 <findonoff+0x44>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    119a <findonoff+0x7a>
lea    -0x30(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1193 <findonoff+0x73>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    119a <findonoff+0x7a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findonoff>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <efindword@plt>
mov    $0x6e6f,%eax
xor    (%rsp),%eax
movzbl 0x2(%rsp),%ecx
or     %ax,%cx
je     1144 <findonoff+0x34>
mov    $0x1,%eax
xor    %ecx,%ecx
cmpl   $0x66666f,(%rsp)
je     1149 <findonoff+0x39>
jmp    114d <findonoff+0x3d>
mov    $0x1,%ecx
mov    %ecx,(%rbx)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @findonoff(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [32 x i8]
store i32* %0, i32** %3
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = call i32 @efindword(i8* %5)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = load i32*, i32** %3
store i32 1, i32* %11
store i32 0, i32* %2
br label %19
12: ; preds = %1
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = load i32*, i32** %3
store i32 0, i32* %17
store i32 0, i32* %2
br label %19
18: ; preds = %12
store i32 1, i32* %2
br label %19
19: ; preds = %18, %16, %10
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
define i32 @findonoff(i32* nocapture writeonly %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = call i32 @efindword(i8* %3)
%5 = call i32 @bcmp(i8* dereferenceable(3) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = bitcast [32 x i8]* %2 to i32*
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 6710895
br i1 %10, label %11, label %13
11: ; preds = %7, %1
%12 = phi i32 [ 1, %1 ], [ 0, %7 ]
store i32 %12, i32* %0
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ 1, %7 ], [ 0, %11 ]
ret i32 %14
}