#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*/ exit(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ write_sys_int(char const *, int);
void do_on_off(char const *path, int argc, char **argv) {
  if (argc != 1) {
    usage();
    exit(1);
  }
  if (strcmp(*argv, "on") == 0) {
    write_sys_int(path, 1);
    return;
  } else if (strcmp(*argv, "off") == 0) {
    write_sys_int(path, 0);
    return;
  } else {
    usage();
    exit(1);
  }
}


x86 assembly (clang, -O0):
<do_on_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     116e <do_on_off+0x2e>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <do_on_off+0x5e>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <write_sys_int@plt>
jmp    11dc <do_on_off+0x9c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11cb <do_on_off+0x8b>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <write_sys_int@plt>
jmp    11dc <do_on_off+0x9c>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_on_off>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%esi
jne    1179 <do_on_off+0x39>
mov    %rdx,%rbx
mov    %rdi,%r14
mov    (%rdx),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118a <do_on_off+0x4a>
mov    (%rbx),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcmp@plt>
xor    %esi,%esi
test   %rax,%rax
je     118f <do_on_off+0x4f>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x1,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <write_sys_int@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define void @do_on_off(i8* %0, i32 %1, i8** nocapture %2) {
%4 = icmp eq i32 %1, 1
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = tail call i32 (...) @usage()
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i32 (...) @usage()
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %12, %8
%20 = phi i32 [ 1, %8 ], [ 0, %12 ]
%21 = tail call i32 @write_sys_int(i8* %0, i32 %20)
ret void
}