#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 */
struct atrf_dsc {
  int dummy;
};

/* Variables and functions */
int EOF;
struct atrf_dsc *atrf_open(char const *);
int /*<<< orphan*/ atrf_reset(struct atrf_dsc *);
int /*<<< orphan*/ atrf_reset_rf(struct atrf_dsc *);
int getopt(int, char *const *, char *);
char *optarg;
int optind;
int /*<<< orphan*/ usage(char *const);
int main(int argc, char *const *argv) {
  const char *driver = NULL;
  struct atrf_dsc *dsc;
  int txrx = 1;
  int c;
  while ((c = getopt(argc, argv, "ad:t")) != EOF)
    switch (c) {
    case 'a':
      txrx = 0;
      break;
    case 'd':
      driver = optarg;
      break;
    case 't':
      txrx = 1;
      break;
    default:
      usage(*argv);
    }
  if (argc != optind)
    usage(*argv);
  dsc = atrf_open(driver);
  if (!dsc)
    return 1;
  if (txrx)
    atrf_reset_rf(dsc);
  else
    atrf_reset(dsc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7d(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%eax
je     120c <main+0xbc>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x61,%eax
je     11d0 <main+0x80>
jmp    11ae <main+0x5e>
mov    -0x2c(%rbp),%eax
sub    $0x64,%eax
je     11dc <main+0x8c>
jmp    11bf <main+0x6f>
mov    -0x2c(%rbp),%eax
sub    $0x74,%eax
je     11ef <main+0x9f>
jmp    11fb <main+0xab>
movl   $0x0,-0x24(%rbp)
jmp    1207 <main+0xb7>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1207 <main+0xb7>
movl   $0x1,-0x24(%rbp)
jmp    1207 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
jmp    1175 <main+0x25>
mov    -0x8(%rbp),%eax
mov    0x2dc2(%rip),%rcx
cmp    (%rcx),%eax
je     122a <main+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    -0x18(%rbp),%rdi
call   1050 <atrf_open@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124e <main+0xfe>
movl   $0x1,-0x4(%rbp)
jmp    1276 <main+0x126>
cmpl   $0x0,-0x24(%rbp)
je     1266 <main+0x116>
mov    -0x20(%rbp),%rdi
call   1040 <atrf_reset_rf@plt>
jmp    126f <main+0x11f>
mov    -0x20(%rbp),%rdi
call   1030 <atrf_reset@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe99(%rip),%rdx
call   1070 <getopt@plt>
mov    0x2e6d(%rip),%r13
cmp    0x0(%r13),%eax
jne    11bc <main+0x6c>
mov    $0x1,%r12d
xor    %r14d,%r14d
mov    0x2e4f(%rip),%rax
cmp    %ebp,(%rax)
je     1195 <main+0x45>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    %r14,%rdi
call   1050 <atrf_open@plt>
test   %rax,%rax
je     1228 <main+0xd8>
mov    %rax,%rdi
test   %r12d,%r12d
je     122f <main+0xdf>
call   1040 <atrf_reset_rf@plt>
jmp    1234 <main+0xe4>
mov    $0x1,%r12d
xor    %r14d,%r14d
lea    0xe34(%rip),%r15
jmp    11eb <main+0x9b>
xchg   %ax,%ax
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    0x0(%r13),%eax
je     1182 <main+0x32>
cmp    $0x61,%eax
je     1210 <main+0xc0>
cmp    $0x74,%eax
je     1220 <main+0xd0>
cmp    $0x64,%eax
jne    11d0 <main+0x80>
mov    0x2df7(%rip),%rax
mov    (%rax),%r14
jmp    11d8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
xor    %r12d,%r12d
jmp    11d8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%r12d
jmp    11d8 <main+0x88>
mov    $0x1,%eax
jmp    1236 <main+0xe6>
call   1030 <atrf_reset@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.atrf_dsc = type { i32 }
@.str = [5 x i8] c"ad:t\00"
@EOF = global i32 0
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.atrf_dsc*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 1, i32* %8
br label %10
10: ; preds = %26, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %10
%17 = load i32, i32* %9
switch i32 %17, label %22 [
i32 97, label %18
i32 100, label %19
i32 116, label %21
]
18: ; preds = %16
store i32 0, i32* %8
br label %26
19: ; preds = %16
%20 = load i8*, i8** @optarg
store i8* %20, i8** %6
br label %26
21: ; preds = %16
store i32 1, i32* %8
br label %26
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = call i32 @usage(i8* %24)
br label %26
26: ; preds = %22, %21, %19, %18
br label %10
27: ; preds = %10
%28 = load i32, i32* %4
%29 = load i32, i32* @optind
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8**, i8*** %5
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33)
br label %35
35: ; preds = %31, %27
%36 = load i8*, i8** %6
%37 = call %struct.atrf_dsc* @atrf_open(i8* %36)
store %struct.atrf_dsc* %37, %struct.atrf_dsc** %7
%38 = load %struct.atrf_dsc*, %struct.atrf_dsc** %7
%39 = icmp ne %struct.atrf_dsc* %38, null
br i1 %39, label %41, label %40
40: ; preds = %35
store i32 1, i32* %3
br label %51
41: ; preds = %35
%42 = load i32, i32* %8
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load %struct.atrf_dsc*, %struct.atrf_dsc** %7
%46 = call i32 @atrf_reset_rf(%struct.atrf_dsc* %45)
br label %50
47: ; preds = %41
%48 = load %struct.atrf_dsc*, %struct.atrf_dsc** %7
%49 = call i32 @atrf_reset(%struct.atrf_dsc* %48)
br label %50
50: ; preds = %47, %44
store i32 0, i32* %3
br label %51
51: ; preds = %50, %40
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
%struct.atrf_dsc = type { i32 }
@.str = [5 x i8] c"ad:t\00"
@EOF = global i32 0
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %22, label %6
6: ; preds = %2, %16
%7 = phi i32 [ %19, %16 ], [ %3, %2 ]
%8 = phi i32 [ %18, %16 ], [ 1, %2 ]
%9 = phi i8* [ %17, %16 ], [ null, %2 ]
switch i32 %7, label %13 [
i32 97, label %16
i32 100, label %10
i32 116, label %12
]
10: ; preds = %6
%11 = load i8*, i8** @optarg
br label %16
12: ; preds = %6
br label %16
13: ; preds = %6
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i8* %14)
br label %16
16: ; preds = %6, %13, %12, %10
%17 = phi i8* [ %9, %13 ], [ %9, %12 ], [ %11, %10 ], [ %9, %6 ]
%18 = phi i32 [ %8, %13 ], [ 1, %12 ], [ %8, %10 ], [ 0, %6 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %6
22: ; preds = %16, %2
%23 = phi i8* [ null, %2 ], [ %17, %16 ]
%24 = phi i32 [ 1, %2 ], [ %18, %16 ]
%25 = load i32, i32* @optind
%26 = icmp eq i32 %25, %0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = load i8*, i8** %1
%29 = tail call i32 @usage(i8* %28)
br label %30
30: ; preds = %27, %22
%31 = tail call %struct.atrf_dsc* @atrf_open(i8* %23)
%32 = icmp eq %struct.atrf_dsc* %31, null
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = icmp eq i32 %24, 0
br i1 %34, label %37, label %35
35: ; preds = %33
%36 = tail call i32 @atrf_reset_rf(%struct.atrf_dsc* %31)
br label %39
37: ; preds = %33
%38 = tail call i32 @atrf_reset(%struct.atrf_dsc* %31)
br label %39
39: ; preds = %35, %37, %30
%40 = phi i32 [ 1, %30 ], [ 0, %37 ], [ 0, %35 ]
ret i32 %40
}