#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 LEGACY_passwordRead(char *, char *, char **, int *);
char *LEGACY_strError(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int err;
  char *ret = NULL;
  int ret_len = 0;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <id>\n", argv[0]);
    return (1);
  }
  err = LEGACY_passwordRead("/", argv[1], &ret, &ret_len);
  if (err != 0) {
    fprintf(stderr, "ERROR: %s\n", LEGACY_strError(err));
    return 1;
  }
  printf("Password: \"");
  fwrite(ret, 1, ret_len, stdout);
  printf("\"\n");
  free(ret);
  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,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b7 <main+0x57>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4a(%rip),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1060 <LEGACY_passwordRead@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1212 <main+0xb2>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <LEGACY_strError@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xe11(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0xf4>
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    0x2dac(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
lea    0xdea(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jne    11c7 <main+0x57>
mov    0x8(%rsi),%rsi
lea    0xe7a(%rip),%rdi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1070 <LEGACY_passwordRead@plt>
test   %eax,%eax
je     11e6 <main+0x76>
mov    0x2e30(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1080 <LEGACY_strError@plt>
lea    0xe52(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
jmp    11da <main+0x6a>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe26(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    1226 <main+0xb6>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    0x2dd6(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1090 <fwrite@plt>
lea    0xe12(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s <id>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [11 x i8] c"ERROR: %s\0A\00"
@.str.3 = [12 x i8] c"Password: \22\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %38
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @LEGACY_passwordRead(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8** %7, i32* %8)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i32, i32* %6
%27 = call i8* @LEGACY_strError(i32 %26)
%28 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 1, i32* %3
br label %38
29: ; preds = %17
%30 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%31 = load i8*, i8** %7
%32 = load i32, i32* %8
%33 = load i32, i32* @stdout
%34 = call i32 @fwrite(i8* %31, i32 1, i32 %32, i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%36 = load i8*, i8** %7
%37 = call i32 @free(i8* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %29, %24, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s <id>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [11 x i8] c"ERROR: %s\0A\00"
@.str.3 = [12 x i8] c"Password: \22\00"
@stdout = global i32 0
@str = [2 x i8] c"\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %30
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @LEGACY_passwordRead(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8** %3, i32* %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i8* @LEGACY_strError(i32 %15)
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %30
21: ; preds = %12
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = load i32, i32* @stdout
%26 = call i32 @fwrite(i8* %23, i32 1, i32 %24, i32 %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%28 = load i8*, i8** %3
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %21, %17, %8
%31 = phi i32 [ 1, %8 ], [ 1, %17 ], [ 0, %21 ]
ret i32 %31
}