#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 *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int br_cmd_stp(char **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    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11a3 <br_cmd_stp+0x63>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11a3 <br_cmd_stp+0x63>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11af <br_cmd_stp+0x6f>
movl   $0x1,-0x14(%rbp)
jmp    123a <br_cmd_stp+0xfa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1206 <br_cmd_stp+0xc6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1206 <br_cmd_stp+0xc6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe18(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1212 <br_cmd_stp+0xd2>
movl   $0x0,-0x14(%rbp)
jmp    1235 <br_cmd_stp+0xf5>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1294 <br_cmd_stp+0x154>
jmp    123a <br_cmd_stp+0xfa>
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     1285 <br_cmd_stp+0x145>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xdb0(%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    %rdi,%rbx
mov    0x10(%rdi),%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(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = getelementptr inbounds i8*, i8** %6, i64 2
%8 = load i8*, i8** %7
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i8**, i8*** %3
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %17, %11, %1
store i32 1, i32* %4
br label %47
24: ; preds = %17
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %42
30: ; preds = %24
%31 = load i8**, i8*** %3
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %30
%37 = load i8**, i8*** %3
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %36, %30, %24
store i32 0, i32* %4
br label %46
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %64
46: ; preds = %42
br label %47
47: ; preds = %46, %23
%48 = load i8**, i8*** %3
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = load i32, i32* %4
%52 = call i32 @br_set_stp_state(i8* %50, i32 %51)
store i32 %52, i32* %5
%53 = load i32, i32* %5
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %47
%56 = load i32, i32* @stderr
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %55, %47
%61 = load i32, i32* %5
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i32
store i32 %63, i32* %2
br label %64
64: ; preds = %60, %43
%65 = load i32, i32* %2
ret i32 %65
}

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(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 2
%3 = load i8*, i8** %2
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %24, label %9
9: ; preds = %6
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %37
24: ; preds = %12, %15, %18, %1, %6, %9
%25 = phi i32 [ 1, %9 ], [ 1, %6 ], [ 1, %1 ], [ 0, %18 ], [ 0, %15 ], [ 0, %12 ]
%26 = getelementptr inbounds i8*, i8** %0, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @br_set_stp_state(i8* %27, i32 %25)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %30, %24
%36 = zext i1 %29 to i32
br label %37
37: ; preds = %35, %21
%38 = phi i32 [ 1, %21 ], [ %36, %35 ]
ret i32 %38
}