#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 rs_authorization {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close_authorizations();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct rs_authorization *lookup_authorization(char *, char *);
int /*<<< orphan*/ open_authorizations(char *);
int /*<<< orphan*/ print_authorization(struct rs_authorization *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: %s <username> <token>\n", argv[0]);
    return 127;
  }
  struct rs_authorization *auth;
  open_authorizations("r");
  auth = lookup_authorization(argv[1], argv[2]);
  close_authorizations();
  if (auth) {
    print_authorization(auth);
    printf("\n");
    return 0;
  } else {
    fprintf(stderr, "No authorization found!\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7f,-0x4(%rbp)
jmp    1217 <main+0xb7>
lea    0xe76(%rip),%rdi
call   1040 <open_authorizations@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1050 <lookup_authorization@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <close_authorizations@plt>
cmpq   $0x0,-0x18(%rbp)
je     11fb <main+0x9b>
mov    -0x18(%rbp),%rdi
call   1070 <print_authorization@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1217 <main+0xb7>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11ba <main+0x4a>
lea    0xe9b(%rip),%rdi
call   1050 <open_authorizations@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
call   1060 <lookup_authorization@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <close_authorizations@plt>
test   %r14,%r14
je     11d2 <main+0x62>
mov    %r14,%rdi
call   1080 <print_authorization@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11ec <main+0x7c>
mov    (%rbx),%rsi
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7f,%ebx
jmp    11ec <main+0x7c>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rs_authorization = type { i32 }
@.str = [30 x i8] c"Usage: %s <username> <token>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"No authorization found!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rs_authorization*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 127, i32* %3
br label %33
14: ; preds = %2
%15 = call i32 @open_authorizations(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call %struct.rs_authorization* @lookup_authorization(i8* %18, i8* %21)
store %struct.rs_authorization* %22, %struct.rs_authorization** %6
%23 = call i32 (...) @close_authorizations()
%24 = load %struct.rs_authorization*, %struct.rs_authorization** %6
%25 = icmp ne %struct.rs_authorization* %24, null
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = load %struct.rs_authorization*, %struct.rs_authorization** %6
%28 = call i32 @print_authorization(%struct.rs_authorization* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %33
30: ; preds = %14
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %33
33: ; preds = %30, %26, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.rs_authorization = type { i32 }
@.str = [30 x i8] c"Usage: %s <username> <token>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"No authorization found!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %22
7: ; preds = %2
%8 = tail call i32 @open_authorizations(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call %struct.rs_authorization* @lookup_authorization(i8* %10, i8* %12)
%14 = tail call i32 (...) @close_authorizations()
%15 = icmp eq %struct.rs_authorization* %13, null
br i1 %15, label %19, label %16
16: ; preds = %7
%17 = tail call i32 @print_authorization(%struct.rs_authorization* %13)
%18 = tail call i32 @putchar(i32 10)
br label %22
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %16, %19, %4
%23 = phi i32 [ 127, %4 ], [ 0, %16 ], [ 1, %19 ]
ret i32 %23
}