#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 */
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ bytes_to_human_string(int /*<<< orphan*/, char *);
char *getpass(char *);
int login(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int query_usage(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s <command> [argument]\n", argv[0]);
    return 1;
  }
  if (strcmp(argv[1], "login") == 0) {
    if (argc < 3) {
      printf("Please provide user name!\n");
      return -1;
    }
    char prompt[31];
    sprintf(prompt, "Enter password for %s: ", argv[2]);
    char *passwd = getpass(prompt);
    int ret = login(argv[2], passwd);
    if (ret == 1)
      printf("Incorrect password!\n");
    else if (ret == -1)
      printf("Login failed. Please try again later.\n");
    else
      printf("Login successful!\n");
  } else if (strcmp(argv[1], "usage") == 0) {
    int64_t month_usage;
    int64_t current_in;
    int64_t current_out;
    if (query_usage(&month_usage, &current_in, &current_out) == -1) {
      printf("Usage query failed. Please try again later.\n");
    } else {
      char buf[31];
      bytes_to_human_string(month_usage, buf);
      printf("Month usage: %s\n", buf);
      bytes_to_human_string(current_in, buf);
      printf("Current in: %s\n", buf);
      bytes_to_human_string(current_out, buf);
      printf("Current out: %s\n", buf);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1334 <main+0x1c4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <main+0x10e>
cmpl   $0x3,-0x8(%rbp)
jge    11f3 <main+0x83>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1334 <main+0x1c4>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe3b(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1080 <getpass@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <login@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
jne    1249 <main+0xd9>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1279 <main+0x109>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1266 <main+0xf6>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1274 <main+0x104>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1279 <main+0x109>
jmp    132d <main+0x1bd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1328 <main+0x1b8>
lea    -0x40(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <query_usage@plt>
cmp    $0xffffffff,%eax
jne    12c9 <main+0x159>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1323 <main+0x1b3>
mov    -0x40(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1070 <bytes_to_human_string@plt>
lea    -0x70(%rbp),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1070 <bytes_to_human_string@plt>
lea    -0x70(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1070 <bytes_to_human_string@plt>
lea    -0x70(%rbp),%rsi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1328 <main+0x1b8>
jmp    132d <main+0x1bd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11ab <main+0x2b>
mov    (%rbx),%rsi
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
jmp    12d8 <main+0x158>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
lea    0xe68(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     125c <main+0xdc>
mov    0x8(%rbx),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    12d8 <main+0x158>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1040 <query_usage@plt>
cmp    $0xffffffff,%eax
je     12cc <main+0x14c>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1080 <bytes_to_human_string@plt>
lea    0xe2e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edi
mov    %r14,%rsi
call   1080 <bytes_to_human_string@plt>
lea    0xe22(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
mov    %r14,%rsi
call   1080 <bytes_to_human_string@plt>
lea    0xe15(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12d8 <main+0x158>
cmp    $0x2,%ebp
ja     1274 <main+0xf4>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    12d8 <main+0x158>
mov    0x10(%rbx),%rdx
lea    0xda7(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
call   1090 <getpass@plt>
mov    0x10(%rbx),%rdi
mov    %rax,%rsi
call   1060 <login@plt>
cmp    $0xffffffff,%eax
lea    0xe0a(%rip),%rcx
lea    0xdf1(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x1,%eax
lea    0xe1b(%rip),%rdi
cmovne %rdx,%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    12d8 <main+0x158>
lea    0xda3(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: %s <command> [argument]\0A\00"
@.str.1 = [6 x i8] c"login\00"
@.str.2 = [27 x i8] c"Please provide user name!\0A\00"
@.str.3 = [24 x i8] c"Enter password for %s: \00"
@.str.4 = [21 x i8] c"Incorrect password!\0A\00"
@.str.5 = [39 x i8] c"Login failed. Please try again later.\0A\00"
@.str.6 = [19 x i8] c"Login successful!\0A\00"
@.str.7 = [6 x i8] c"usage\00"
@.str.8 = [45 x i8] c"Usage query failed. Please try again later.\0A\00"
@.str.9 = [17 x i8] c"Month usage: %s\0A\00"
@.str.10 = [16 x i8] c"Current in: %s\0A\00"
@.str.11 = [17 x i8] c"Current out: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [31 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [31 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %87
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %57
26: ; preds = %20
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %87
31: ; preds = %26
%32 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%38 = call i8* @getpass(i8* %37)
store i8* %38, i8** %7
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = load i8*, i8** %7
%43 = call i32 @login(i8* %41, i8* %42)
store i32 %43, i32* %8
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %31
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %56
48: ; preds = %31
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %55
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
br label %56
56: ; preds = %55, %46
br label %86
57: ; preds = %20
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %85
63: ; preds = %57
%64 = call i32 @query_usage(i32* %9, i32* %10, i32* %11)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %84
68: ; preds = %63
%69 = load i32, i32* %9
%70 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%71 = call i32 @bytes_to_human_string(i32 %69, i8* %70)
%72 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %10
%75 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%76 = call i32 @bytes_to_human_string(i32 %74, i8* %75)
%77 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %77)
%79 = load i32, i32* %11
%80 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%81 = call i32 @bytes_to_human_string(i32 %79, i8* %80)
%82 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %68, %66
br label %85
85: ; preds = %84, %57
br label %86
86: ; preds = %85, %56
store i32 0, i32* %3
br label %87
87: ; preds = %86, %29, %15
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [32 x i8] c"Usage: %s <command> [argument]\0A\00"
@.str.1 = [6 x i8] c"login\00"
@.str.3 = [24 x i8] c"Enter password for %s: \00"
@.str.7 = [6 x i8] c"usage\00"
@.str.9 = [17 x i8] c"Month usage: %s\0A\00"
@.str.10 = [16 x i8] c"Current in: %s\0A\00"
@.str.11 = [17 x i8] c"Current out: %s\0A\00"
@str = [44 x i8] c"Usage query failed. Please try again later.\00"
@str.12 = [18 x i8] c"Login successful!\00"
@str.13 = [38 x i8] c"Login failed. Please try again later.\00"
@str.14 = [20 x i8] c"Incorrect password!\00"
@str.15 = [26 x i8] c"Please provide user name!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [31 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [31 x i8]
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %58
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %12
%18 = icmp ult i32 %0, 3
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
br label %58
21: ; preds = %17
%22 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = call i8* @getpass(i8* %22)
%27 = load i8*, i8** %23
%28 = call i32 @login(i8* %27, i8* %26)
%29 = icmp eq i32 %28, -1
%30 = select i1 %29, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0)
%31 = icmp eq i32 %28, 1
%32 = select i1 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0), i8* %30
%33 = call i32 @puts(i8* dereferenceable(1) %32)
br label %58
34: ; preds = %12
%35 = load i8*, i8** %13
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %58
38: ; preds = %34
%39 = bitcast i32* %4 to i8*
%40 = bitcast i32* %5 to i8*
%41 = bitcast i32* %6 to i8*
%42 = call i32 @query_usage(i32* %4, i32* %5, i32* %6)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %57
46: ; preds = %38
%47 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%48 = load i32, i32* %4
%49 = call i32 @bytes_to_human_string(i32 %48, i8* %47)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %47)
%51 = load i32, i32* %5
%52 = call i32 @bytes_to_human_string(i32 %51, i8* %47)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %47)
%54 = load i32, i32* %6
%55 = call i32 @bytes_to_human_string(i32 %54, i8* %47)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* %47)
br label %57
57: ; preds = %46, %44
br label %58
58: ; preds = %21, %57, %34, %19, %9
%59 = phi i32 [ 1, %9 ], [ -1, %19 ], [ 0, %34 ], [ 0, %57 ], [ 0, %21 ]
ret i32 %59
}