#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 br_set_stp_state(char *const, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *const, char *);
char *strerror(int /*<<< orphan*/);
int br_cmd_stp(int argc, char *const *argv) {
  int stp, err;
  if (!strcmp(argv[2], "on") || !strcmp(argv[2], "yes") ||
      !strcmp(argv[2], "1"))
    stp = 1;
  else if (!strcmp(argv[2], "off") || !strcmp(argv[2], "no") ||
           !strcmp(argv[2], "0"))
    stp = 0;
  else {
    fprintf(stderr, "expect on/off for argument\n");
    return 1;
  }
  err = br_set_stp_state(argv[1], stp);
  if (err)
    fprintf(stderr, "set stp status failed: %s\n", strerror(errno));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_stp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11a6 <br_cmd_stp+0x66>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11a6 <br_cmd_stp+0x66>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b2 <br_cmd_stp+0x72>
movl   $0x1,-0x14(%rbp)
jmp    123d <br_cmd_stp+0xfd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1209 <br_cmd_stp+0xc9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1209 <br_cmd_stp+0xc9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe15(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1215 <br_cmd_stp+0xd5>
movl   $0x0,-0x14(%rbp)
jmp    1238 <br_cmd_stp+0xf8>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1297 <br_cmd_stp+0x157>
jmp    123d <br_cmd_stp+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1050 <br_set_stp_state@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1288 <br_cmd_stp+0x148>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_stp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x10(%rsi),%rbp
lea    0xeae(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%r14d
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
lea    0xe94(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
lea    0xe85(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
lea    0xe74(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
lea    0xe62(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
lea    0xe52(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <br_cmd_stp+0xa8>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    122b <br_cmd_stp+0xeb>
mov    0x8(%rbx),%rdi
mov    %r14d,%esi
call   1050 <br_set_stp_state@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1224 <br_cmd_stp+0xe4>
mov    0x2ddf(%rip),%rax
mov    (%rax),%ebp
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe16(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
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"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.6 = [28 x i8] c"expect on/off for argument\0A\00"
@.str.7 = [27 x i8] c"set stp status failed: %s\0A\00"
@errno = global i32 0
define i32 @br_cmd_stp(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %19, %13, %2
store i32 1, i32* %6
br label %49
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %38, %32, %26
store i32 0, i32* %6
br label %48
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %66
48: ; preds = %44
br label %49
49: ; preds = %48, %25
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = load i32, i32* %6
%54 = call i32 @br_set_stp_state(i8* %52, i32 %53)
store i32 %54, i32* %7
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %49
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %57, %49
%63 = load i32, i32* %7
%64 = icmp ne i32 %63, 0
%65 = zext i1 %64 to i32
store i32 %65, i32* %3
br label %66
66: ; preds = %62, %45
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.6 = [28 x i8] c"expect on/off for argument\0A\00"
@.str.7 = [27 x i8] c"set stp status failed: %s\0A\00"
@errno = global i32 0
define i32 @br_cmd_stp(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %38
25: ; preds = %13, %16, %19, %2, %7, %10
%26 = phi i32 [ 1, %10 ], [ 1, %7 ], [ 1, %2 ], [ 0, %19 ], [ 0, %16 ], [ 0, %13 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = tail call i32 @br_set_stp_state(i8* %28, i32 %26)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = tail call i8* @strerror(i32 %33)
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %25
%37 = zext i1 %30 to i32
br label %38
38: ; preds = %36, %22
%39 = phi i32 [ 1, %22 ], [ %37, %36 ]
ret i32 %39
}