#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gpio_init();
int /*<<< orphan*/ gpio_setpullup(int, int);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int x, gpio, p;
  char arg[64];
  gpio_init();
  for (x = 1; x < argc; ++x) {
    if (sscanf(argv[x], "%d=%s", &gpio, arg) != 2)
      goto errxit;
    if (*arg == 'n')
      p = -1;
    else if (*arg == 'l' || *arg == 'h')
      p = *arg == 'h' ? 1 : 0;
    else
      goto errxit;
    if (gpio < 0 || gpio > 31) {
      fprintf(stderr, "%s: GPIO must be <= 31\n", argv[x]);
      return 1;
    }
    gpio_setpullup(gpio, p);
  }
  return 0;
errxit:
  fprintf(stderr,
          "Argument '%s' must be in the form\n"
          "  <gpio>=<arg> where arg is h, l or n.\n",
          argv[x]);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <gpio_init@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124e <main+0x10e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x60(%rbp),%rcx
lea    0xe79(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     119e <main+0x5e>
jmp    125a <main+0x11a>
movsbl -0x60(%rbp),%eax
cmp    $0x6e,%eax
jne    11b7 <main+0x77>
movl   $0xffffffff,-0x1c(%rbp)
jmp    11f4 <main+0xb4>
movsbl -0x60(%rbp),%eax
cmp    $0x6c,%eax
je     11d1 <main+0x91>
movsbl -0x60(%rbp),%eax
cmp    $0x68,%eax
jne    11ea <main+0xaa>
movsbl -0x60(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x68,%edx
cmove  %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ef <main+0xaf>
jmp    125a <main+0x11a>
jmp    11f4 <main+0xb4>
cmpl   $0x0,-0x18(%rbp)
jl     1208 <main+0xc8>
cmpl   $0x1f,-0x18(%rbp)
jle    1235 <main+0xf5>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde2(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1282 <main+0x142>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <gpio_setpullup@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x24>
movl   $0x0,-0x4(%rbp)
jmp    1282 <main+0x142>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xda8(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <gpio_init@plt>
cmp    $0x2,%ebp
jl     11f9 <main+0xb9>
mov    %ebp,%r15d
mov    $0x1,%r14d
lea    0xe8b(%rip),%rbx
lea    0xc(%rsp),%r13
lea    0x10(%rsp),%rbp
nop
mov    (%r12,%r14,8),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11d2 <main+0x92>
movzbl 0x10(%rsp),%eax
mov    $0xffffffff,%esi
cmp    $0x6e,%al
je     11b7 <main+0x77>
mov    %eax,%ecx
and    $0xfb,%cl
cmp    $0x68,%cl
jne    11d2 <main+0x92>
xor    %esi,%esi
cmp    $0x68,%al
sete   %sil
mov    0xc(%rsp),%edi
cmp    $0x1f,%edi
ja     11db <main+0x9b>
call   1030 <gpio_setpullup@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    1180 <main+0x40>
xor    %ebx,%ebx
jmp    11f9 <main+0xb9>
lea    0xe45(%rip),%rsi
jmp    11e2 <main+0xa2>
lea    0xe24(%rip),%rsi
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%r14,8),%rdx
call   1040 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d=%s\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: GPIO must be <= 31\0A\00"
@.str.2 = [74 x i8] c"Argument '%s' must be in the form\0A <gpio>=<arg> where arg is h, l or n.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (...) @gpio_init()
store i32 1, i32* %6
br label %11
11: ; preds = %68, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %71
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%22 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %7, i8* %21)
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %25
24: ; preds = %15
br label %72
25: ; preds = %15
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 110
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 -1, i32* %8
br label %50
31: ; preds = %25
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 108
br i1 %35, label %41, label %36
36: ; preds = %31
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 104
br i1 %40, label %41, label %48
41: ; preds = %36, %31
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 104
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 1, i32 0
store i32 %47, i32* %8
br label %49
48: ; preds = %36
br label %72
49: ; preds = %41
br label %50
50: ; preds = %49, %30
%51 = load i32, i32* %7
%52 = icmp slt i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = load i32, i32* %7
%55 = icmp sgt i32 %54, 31
br i1 %55, label %56, label %64
56: ; preds = %53, %50
%57 = load i32, i32* @stderr
%58 = load i8**, i8*** %5
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %62)
store i32 1, i32* %3
br label %80
64: ; preds = %53
%65 = load i32, i32* %7
%66 = load i32, i32* %8
%67 = call i32 @gpio_setpullup(i32 %65, i32 %66)
br label %68
68: ; preds = %64
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %11
71: ; preds = %11
store i32 0, i32* %3
br label %80
72: ; preds = %48, %24
%73 = load i32, i32* @stderr
%74 = load i8**, i8*** %5
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %78)
store i32 1, i32* %3
br label %80
80: ; preds = %72, %71, %56
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d=%s\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: GPIO must be <= 31\0A\00"
@.str.2 = [74 x i8] c"Argument '%s' must be in the form\0A <gpio>=<arg> where arg is h, l or n.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (...) @gpio_init()
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %41
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %30
%12 = phi i64 [ 1, %9 ], [ %32, %30 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %6)
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %34
17: ; preds = %11
%18 = load i8, i8* %6
%19 = icmp eq i8 %18, 110
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = and i8 %18, -5
%22 = icmp eq i8 %21, 104
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = icmp eq i8 %18, 104
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %17, %23
%27 = phi i32 [ %25, %23 ], [ -1, %17 ]
%28 = load i32, i32* %3
%29 = icmp ugt i32 %28, 31
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = call i32 @gpio_setpullup(i32 %28, i32 %27)
%32 = add nuw nsw i64 %12, 1
%33 = icmp eq i64 %32, %10
br i1 %33, label %41, label %11
34: ; preds = %11, %20, %26
%35 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %26 ], [ getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), %20 ], [ getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), %11 ]
%36 = and i64 %12, 4294967295
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %37
%40 = call i32 @fprintf(i32 %38, i8* %35, i8* %39)
br label %41
41: ; preds = %30, %34, %2
%42 = phi i32 [ 0, %2 ], [ 1, %34 ], [ 0, %30 ]
ret i32 %42
}