#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int getopt(int, char **, char *);
int hammer_device(char const *, unsigned int *, int, unsigned int);
char *optarg;
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ stderr;
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 num_lines;
  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':
      if (i < GPIOHANDLES_MAX)
        lines[i] = strtoul(optarg, NULL, 10);
      i++;
      break;
    case '?':
      print_usage();
      return -1;
    }
  }
  if (i >= GPIOHANDLES_MAX) {
    fprintf(stderr, "Only %d occurrences of '-o' are allowed, %d were found\n",
            GPIOHANDLES_MAX, i + 1);
    return -1;
  }
  num_lines = i;
  if (!device_name || !num_lines) {
    print_usage();
    return -1;
  }
  return hammer_device(device_name, lines, num_lines, 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    0x2e6b(%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    0xe49(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     12a6 <main+0x156>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x3f,%eax
je     1287 <main+0x137>
jmp    11dc <main+0x8c>
mov    -0x4c(%rbp),%eax
sub    $0x63,%eax
je     120f <main+0xbf>
jmp    11ed <main+0x9d>
mov    -0x4c(%rbp),%eax
sub    $0x6e,%eax
je     122f <main+0xdf>
jmp    11fe <main+0xae>
mov    -0x4c(%rbp),%eax
sub    $0x6f,%eax
je     1242 <main+0xf2>
jmp    12a1 <main+0x151>
mov    0x2de2(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
jmp    12a1 <main+0x151>
mov    0x2dc2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    12a1 <main+0x151>
mov    -0x38(%rbp),%eax
mov    0x2d94(%rip),%rcx
cmp    (%rcx),%eax
jge    1279 <main+0x129>
mov    0x2d9d(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <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    12a1 <main+0x151>
mov    $0x0,%al
call   1060 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1341 <main+0x1f1>
jmp    11a9 <main+0x59>
mov    -0x38(%rbp),%eax
mov    0x2d30(%rip),%rcx
cmp    (%rcx),%eax
jl     12ef <main+0x19f>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    0x2d18(%rip),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
lea    0xd31(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1341 <main+0x1f1>
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     130a <main+0x1ba>
cmpl   $0x0,-0x30(%rbp)
jne    1324 <main+0x1d4>
mov    $0x0,%al
call   1060 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1341 <main+0x1f1>
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1070 <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,%r12
mov    %edi,%ebx
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    0xe6f(%rip),%r13
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <getopt@plt>
cmp    $0x62,%eax
jle    11e0 <main+0x90>
cmp    $0x6f,%eax
je     11ec <main+0x9c>
cmp    $0x6e,%eax
je     121b <main+0xcb>
cmp    $0x63,%eax
jne    11a0 <main+0x50>
mov    0x2e30(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x30(%rbp)
jmp    11a0 <main+0x50>
nopl   (%rax)
cmp    $0xffffffff,%eax
je     122e <main+0xde>
cmp    $0x3f,%eax
jne    11a0 <main+0x50>
jmp    125b <main+0x10b>
mov    0x2ded(%rip),%rax
cmp    (%rax),%r14d
jge    1215 <main+0xc5>
mov    0x2df9(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
movslq %r14d,%rcx
mov    %eax,(%r15,%rcx,4)
add    $0x1,%r14d
jmp    11a0 <main+0x50>
mov    0x2dd6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    11a0 <main+0x50>
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
cmp    %edx,%r14d
jge    1264 <main+0x114>
mov    -0x38(%rbp),%rdi
test   %rdi,%rdi
je     125b <main+0x10b>
test   %r14d,%r14d
je     125b <main+0x10b>
mov    %r15,%rsi
mov    %r14d,%edx
mov    -0x30(%rbp),%rcx
call   1070 <hammer_device@plt>
jmp    1285 <main+0x135>
xor    %eax,%eax
call   1060 <print_usage@plt>
jmp    1280 <main+0x130>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
add    $0x1,%r14d
lea    0xd90(%rip),%rsi
mov    %r14d,%ecx
call   1030 <fprintf@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
@stderr = global i32 0
@.str.1 = [56 x i8] c"Only %d occurrences of '-o' are allowed, %d were found\0A\00"
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 = %45, %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 %46
23: ; preds = %18
%24 = load i32, i32* %11
switch i32 %24, label %45 [
i32 99, label %25
i32 110, label %28
i32 111, label %30
i32 63, label %43
]
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 %45
28: ; preds = %23
%29 = load i8*, i8** @optarg
store i8* %29, i8** %6
br label %45
30: ; preds = %23
%31 = load i32, i32* %12
%32 = load i32, i32* @GPIOHANDLES_MAX
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i8*, i8** @optarg
%36 = call i32 @strtoul(i8* %35, i32* null, i32 10)
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %17, i64 %38
store i32 %36, i32* %39
br label %40
40: ; preds = %34, %30
%41 = load i32, i32* %12
%42 = add nsw i32 %41, 1
store i32 %42, i32* %12
br label %45
43: ; preds = %23
%44 = call i32 (...) @print_usage()
store i32 -1, i32* %3
store i32 1, i32* %13
br label %70
45: ; preds = %23, %40, %28, %25
br label %18
46: ; preds = %18
%47 = load i32, i32* %12
%48 = load i32, i32* @GPIOHANDLES_MAX
%49 = icmp sge i32 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = load i32, i32* @GPIOHANDLES_MAX
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
%55 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %52, i32 %54)
store i32 -1, i32* %3
store i32 1, i32* %13
br label %70
56: ; preds = %46
%57 = load i32, i32* %12
store i32 %57, i32* %10
%58 = load i8*, i8** %6
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32, i32* %10
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60, %56
%64 = call i32 (...) @print_usage()
store i32 -1, i32* %3
store i32 1, i32* %13
br label %70
65: ; preds = %60
%66 = load i8*, i8** %6
%67 = load i32, i32* %10
%68 = load i32, i32* %9
%69 = call i32 @hammer_device(i8* %66, i32* %17, i32 %67, i32 %68)
store i32 %69, i32* %3
store i32 1, i32* %13
br label %70
70: ; preds = %65, %63, %50, %43
%71 = load i8*, i8** %7
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@GPIOHANDLES_MAX = global i32 0
@.str = [8 x i8] c"c:n:o:?\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [56 x i8] c"Only %d occurrences of '-o' are allowed, %d were found\0A\00"
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, %30
%14 = phi i32 [ %12, %10 ], [ %31, %30 ]
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 %34
i32 99, label %17
i32 110, label %20
i32 111, label %22
i32 63, label %32
]
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 i32, i32* @GPIOHANDLES_MAX
%24 = icmp slt i32 %14, %23
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8*, i8** @optarg
%27 = tail call i32 @strtoul(i8* nocapture %26, i32* null, i32 10)
%28 = sext i32 %14 to i64
%29 = getelementptr inbounds i32, i32* %5, i64 %28
store i32 %27, i32* %29
br label %30
30: ; preds = %25, %22
%31 = add nsw i32 %14, 1
br label %13
32: ; preds = %15
%33 = tail call i32 (...) @print_usage()
br label %49
34: ; preds = %15
%35 = load i32, i32* @GPIOHANDLES_MAX
%36 = icmp slt i32 %14, %35
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = add nsw i32 %14, 1
%40 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %39)
br label %49
41: ; preds = %34
%42 = icmp ne i8* %11, null
%43 = icmp ne i32 %14, 0
%44 = select i1 %42, i1 %43, i1 false
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = tail call i32 (...) @print_usage()
br label %49
47: ; preds = %41
%48 = call i32 @hammer_device(i8* %11, i32* %5, i32 %14, i32 %7)
br label %49
49: ; preds = %47, %45, %37, %32
%50 = phi i32 [ -1, %32 ], [ -1, %37 ], [ %48, %47 ], [ -1, %45 ]
ret i32 %50
}