#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 GPIOHANDLES_MAX;
int getopt(int, char **, char *);
int hammer_device(char const *, unsigned int *, int, unsigned int);
char *optarg;
int /*<<< orphan*/ print_usage();
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  const char *device_name = NULL;
  unsigned int lines[GPIOHANDLES_MAX];
  unsigned int loops = 0;
  int nlines;
  int c;
  int i;
  i = 0;
  while ((c = getopt(argc, argv, "c:n:o:?")) != -1) {
    switch (c) {
    case 'c':
      loops = strtoul(optarg, NULL, 10);
      break;
    case 'n':
      device_name = optarg;
      break;
    case 'o':
      lines[i] = strtoul(optarg, NULL, 10);
      i++;
      break;
    case '?':
      print_usage();
      return -1;
    }
  }
  nlines = i;
  if (!device_name || !nlines) {
    print_usage();
    return -1;
  }
  return hammer_device(device_name, lines, nlines, loops);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdx
call   1030 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1284 <main+0x144>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x3f,%eax
je     1265 <main+0x125>
jmp    11cc <main+0x8c>
mov    -0x4c(%rbp),%eax
sub    $0x63,%eax
je     11ff <main+0xbf>
jmp    11dd <main+0x9d>
mov    -0x4c(%rbp),%eax
sub    $0x6e,%eax
je     121f <main+0xdf>
jmp    11ee <main+0xae>
mov    -0x4c(%rbp),%eax
sub    $0x6f,%eax
je     1232 <main+0xf2>
jmp    127f <main+0x13f>
mov    0x2df2(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
jmp    127f <main+0x13f>
mov    0x2dd2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    127f <main+0x13f>
mov    0x2dbf(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    127f <main+0x13f>
mov    $0x0,%al
call   1050 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12d6 <main+0x196>
jmp    1199 <main+0x59>
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     129f <main+0x15f>
cmpl   $0x0,-0x30(%rbp)
jne    12b9 <main+0x179>
mov    $0x0,%al
call   1050 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12d6 <main+0x196>
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1060 <hammer_device@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    0xe7f(%rip),%r13
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r13,%rdx
call   1030 <getopt@plt>
cmp    $0x62,%eax
jle    11d0 <main+0x90>
cmp    $0x6f,%eax
je     11dc <main+0x9c>
cmp    $0x6e,%eax
je     11ff <main+0xbf>
cmp    $0x63,%eax
jne    1190 <main+0x50>
mov    0x2e40(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x30(%rbp)
jmp    1190 <main+0x50>
nopl   (%rax)
cmp    $0xffffffff,%eax
je     120f <main+0xcf>
cmp    $0x3f,%eax
jne    1190 <main+0x50>
jmp    122e <main+0xee>
mov    0x2e15(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
movslq %r12d,%r12
mov    %eax,(%r14,%r12,4)
add    $0x1,%r12d
jmp    1190 <main+0x50>
mov    0x2df2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1190 <main+0x50>
mov    -0x38(%rbp),%rdi
test   %rdi,%rdi
je     122e <main+0xee>
test   %r12d,%r12d
je     122e <main+0xee>
mov    %r14,%rsi
mov    %r12d,%edx
mov    -0x30(%rbp),%rcx
call   1060 <hammer_device@plt>
jmp    123a <main+0xfa>
xor    %eax,%eax
call   1050 <print_usage@plt>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GPIOHANDLES_MAX = global i32 0
@.str = [8 x i8] c"c:n:o:?\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%14 = load i32, i32* @GPIOHANDLES_MAX
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %7
%17 = alloca i32, i64 %15
store i64 %15, i64* %8
store i32 0, i32* %9
store i32 0, i32* %12
br label %18
18: ; preds = %40, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %11
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %41
23: ; preds = %18
%24 = load i32, i32* %11
switch i32 %24, label %40 [
i32 99, label %25
i32 110, label %28
i32 111, label %30
i32 63, label %38
]
25: ; preds = %23
%26 = load i8*, i8** @optarg
%27 = call i32 @strtoul(i8* %26, i32* null, i32 10)
store i32 %27, i32* %9
br label %40
28: ; preds = %23
%29 = load i8*, i8** @optarg
store i8* %29, i8** %6
br label %40
30: ; preds = %23
%31 = load i8*, i8** @optarg
%32 = call i32 @strtoul(i8* %31, i32* null, i32 10)
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %17, i64 %34
store i32 %32, i32* %35
%36 = load i32, i32* %12
%37 = add nsw i32 %36, 1
store i32 %37, i32* %12
br label %40
38: ; preds = %23
%39 = call i32 (...) @print_usage()
store i32 -1, i32* %3
store i32 1, i32* %13
br label %55
40: ; preds = %23, %30, %28, %25
br label %18
41: ; preds = %18
%42 = load i32, i32* %12
store i32 %42, i32* %10
%43 = load i8*, i8** %6
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %10
%47 = icmp ne i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45, %41
%49 = call i32 (...) @print_usage()
store i32 -1, i32* %3
store i32 1, i32* %13
br label %55
50: ; preds = %45
%51 = load i8*, i8** %6
%52 = load i32, i32* %10
%53 = load i32, i32* %9
%54 = call i32 @hammer_device(i8* %51, i32* %17, i32 %52, i32 %53)
store i32 %54, i32* %3
store i32 1, i32* %13
br label %55
55: ; preds = %50, %48, %38
%56 = load i8*, i8** %7
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@GPIOHANDLES_MAX = global i32 0
@.str = [8 x i8] c"c:n:o:?\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @GPIOHANDLES_MAX
%4 = zext i32 %3 to i64
%5 = alloca i32, i64 %4
br label %6
6: ; preds = %17, %2
%7 = phi i32 [ %19, %17 ], [ 0, %2 ]
%8 = phi i8* [ %11, %17 ], [ null, %2 ]
%9 = phi i32 [ %14, %17 ], [ 0, %2 ]
br label %10
10: ; preds = %6, %20
%11 = phi i8* [ %8, %6 ], [ %21, %20 ]
%12 = phi i32 [ %9, %6 ], [ %14, %20 ]
br label %13
13: ; preds = %10, %22
%14 = phi i32 [ %12, %10 ], [ %27, %22 ]
br label %15
15: ; preds = %13, %15
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %16, label %15 [
i32 -1, label %30
i32 99, label %17
i32 110, label %20
i32 111, label %22
i32 63, label %28
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
%19 = tail call i32 @strtoul(i8* nocapture %18, i32* null, i32 10)
br label %6
20: ; preds = %15
%21 = load i8*, i8** @optarg
br label %10
22: ; preds = %15
%23 = load i8*, i8** @optarg
%24 = tail call i32 @strtoul(i8* nocapture %23, i32* null, i32 10)
%25 = sext i32 %14 to i64
%26 = getelementptr inbounds i32, i32* %5, i64 %25
store i32 %24, i32* %26
%27 = add nsw i32 %14, 1
br label %13
28: ; preds = %15
%29 = tail call i32 (...) @print_usage()
br label %38
30: ; preds = %15
%31 = icmp ne i8* %11, null
%32 = icmp ne i32 %14, 0
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = tail call i32 (...) @print_usage()
br label %38
36: ; preds = %30
%37 = call i32 @hammer_device(i8* %11, i32* %5, i32 %14, i32 %7)
br label %38
38: ; preds = %36, %34, %28
%39 = phi i32 [ -1, %28 ], [ %37, %36 ], [ -1, %34 ]
ret i32 %39
}