#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ keypad_fgets(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage(int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  int c;
  int quiet = 0;
  int repeate = 0;
  char input[80];
  while ((c = getopt(argc, argv, "vqrh?")) > 0) {
    switch (c) {
    case 'v':
      printf("%s: version %s\n", argv[0], "0.1");
      exit(0);
    case 'q':
      quiet++;
      break;
    case 'r':
      repeate++;
      break;
    case 'h':
    case '?':
      usage(stdout, 0);
      break;
    default:
      fprintf(stderr, "ERROR: unkown option '%c'\n", c);
      usage(stderr, 1);
      break;
    }
  }
  if (!quiet)
    printf(" TWI Keypad Test Application\n\n");
  do {
    keypad_fgets(input, 80);
    if (!quiet)
      printf("Entry was: %s \n", input);
    else
      printf("%s", input);
    fflush(stdout);
  } while (repeate);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1292 <main+0x122>
mov    -0x14(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x3f,%eax
je     124d <main+0xdd>
jmp    11ca <main+0x5a>
mov    -0x74(%rbp),%eax
sub    $0x68,%eax
je     124d <main+0xdd>
jmp    11db <main+0x6b>
mov    -0x74(%rbp),%eax
sub    $0x71,%eax
je     1231 <main+0xc1>
jmp    11ec <main+0x7c>
mov    -0x74(%rbp),%eax
sub    $0x72,%eax
je     123f <main+0xcf>
jmp    11fd <main+0x8d>
mov    -0x74(%rbp),%eax
sub    $0x76,%eax
jne    1262 <main+0xf2>
jmp    120e <main+0x9e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdea(%rip),%rdi
lea    0xdf3(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    128d <main+0x11d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    128d <main+0x11d>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <usage@plt>
jmp    128d <main+0x11d>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xda5(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <usage@plt>
jmp    1197 <main+0x27>
cmpl   $0x0,-0x18(%rbp)
jne    12aa <main+0x13a>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x13f>
lea    -0x70(%rbp),%rdi
mov    $0x50,%esi
call   1050 <keypad_fgets@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12de <main+0x16e>
lea    -0x70(%rbp),%rsi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f0 <main+0x180>
lea    -0x70(%rbp),%rsi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12af <main+0x13f>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea2(%rip),%rdx
call   1090 <getopt@plt>
xor    %r12d,%r12d
test   %eax,%eax
jle    124d <main+0xcd>
xor    %r12d,%r12d
lea    0xe88(%rip),%r14
lea    0xe45(%rip),%r13
movl   $0x0,0xc(%rsp)
jmp    11f1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1080 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
test   %eax,%eax
jle    1246 <main+0xc6>
lea    -0x68(%rax),%ecx
cmp    $0xe,%ecx
ja     1210 <main+0x90>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
addl   $0x1,0xc(%rsp)
jmp    11e0 <main+0x60>
nopw   0x0(%rax,%rax,1)
cmp    $0x3f,%eax
je     11d0 <main+0x50>
mov    0x2dc4(%rip),%r15
mov    (%r15),%edi
lea    0xe30(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    (%r15),%edi
mov    $0x1,%esi
jmp    11db <main+0x5b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
jmp    11e0 <main+0x60>
cmpl   $0x0,0xc(%rsp)
jne    1262 <main+0xe2>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
lea    0xe11(%rip),%rbx
jmp    1269 <main+0xe9>
lea    0xe18(%rip),%rbx
lea    0x10(%rsp),%rbp
mov    0x2d63(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    $0x50,%esi
call   1060 <keypad_fgets@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edi
call   1070 <fflush@plt>
test   %r12d,%r12d
jne    1280 <main+0x100>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    (%rbx),%rsi
lea    0xd8a(%rip),%rdi
lea    0xd93(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"vqrh?\00"
@.str.1 = [16 x i8] c"%s: version %s\0A\00"
@.str.2 = [4 x i8] c"0.1\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [27 x i8] c"ERROR: unkown option '%c'\0A\00"
@.str.4 = [31 x i8] c" TWI Keypad Test Application\0A\0A\00"
@.str.5 = [16 x i8] c"Entry was: %s \0A\00"
@.str.6 = [3 x i8] c"%s\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 [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %32 [
i32 118, label %17
i32 113, label %23
i32 114, label %26
i32 104, label %29
i32 63, label %29
]
17: ; preds = %15
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %15
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %38
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %38
29: ; preds = %15, %15
%30 = load i32, i32* @stdout
%31 = call i32 @usage(i32 %30, i32 0)
br label %38
32: ; preds = %15
%33 = load i32, i32* @stderr
%34 = load i32, i32* %6
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @stderr
%37 = call i32 @usage(i32 %36, i32 1)
br label %38
38: ; preds = %32, %29, %26, %23
br label %10
39: ; preds = %10
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
br label %45
45: ; preds = %59, %44
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%47 = call i32 @keypad_fgets(i8* %46, i32 80)
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %45
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %51)
br label %56
53: ; preds = %45
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %50
%57 = load i32, i32* @stdout
%58 = call i32 @fflush(i32 %57)
br label %59
59: ; preds = %56
%60 = load i32, i32* %8
%61 = icmp ne i32 %60, 0
br i1 %61, label %45, label %62
62: ; preds = %59
%63 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"vqrh?\00"
@.str.1 = [16 x i8] c"%s: version %s\0A\00"
@.str.2 = [4 x i8] c"0.1\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [27 x i8] c"ERROR: unkown option '%c'\0A\00"
@.str.5 = [16 x i8] c"Entry was: %s \0A\00"
@.str.6 = [3 x i8] c"%s\00"
@str = [30 x i8] c" TWI Keypad Test Application\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %2, %27
%8 = phi i32 [ %30, %27 ], [ %5, %2 ]
%9 = phi i32 [ %29, %27 ], [ 0, %2 ]
%10 = phi i32 [ %28, %27 ], [ 0, %2 ]
switch i32 %8, label %22 [
i32 118, label %11
i32 113, label %15
i32 114, label %17
i32 104, label %19
i32 63, label %19
]
11: ; preds = %7
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %7
%16 = add nsw i32 %10, 1
br label %27
17: ; preds = %7
%18 = add nsw i32 %9, 1
br label %27
19: ; preds = %7, %7
%20 = load i32, i32* @stdout
%21 = tail call i32 @usage(i32 %20, i32 0)
br label %27
22: ; preds = %7
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%25 = load i32, i32* @stderr
%26 = tail call i32 @usage(i32 %25, i32 1)
br label %27
27: ; preds = %22, %19, %17, %15
%28 = phi i32 [ %10, %22 ], [ %10, %19 ], [ %10, %17 ], [ %16, %15 ]
%29 = phi i32 [ %9, %22 ], [ %9, %19 ], [ %18, %17 ], [ %9, %15 ]
%30 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%31 = icmp sgt i32 %30, 0
br i1 %31, label %7, label %32
32: ; preds = %27
%33 = icmp eq i32 %28, 0
br i1 %33, label %34, label %37
34: ; preds = %2, %32
%35 = phi i32 [ %29, %32 ], [ 0, %2 ]
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %34, %32
%38 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), %34 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %32 ]
%39 = phi i32 [ %35, %34 ], [ %29, %32 ]
%40 = icmp eq i32 %39, 0
br label %41
41: ; preds = %41, %37
%42 = call i32 @keypad_fgets(i8* %4, i32 80)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %38, i8* %4)
%44 = load i32, i32* @stdout
%45 = call i32 @fflush(i32 %44)
br i1 %40, label %46, label %41
46: ; preds = %41
%47 = call i32 @exit(i32 0)
unreachable
}