#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_passwordWrite(char *, char *, char *, int /*<<< orphan*/, int);
char *LEGACY_strError(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  int err;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <id> <pwd>\n", argv[0]);
    return (1);
  }
  err = LEGACY_passwordWrite("/", argv[1], argv[2], strlen(argv[2]), 0600);
  if (err != 0) {
    fprintf(stderr, "ERROR: %s\n", LEGACY_strError(err));
    return 1;
  }
  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)
cmpl   $0x3,-0x8(%rbp)
je     1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe58(%rip),%rdi
mov    $0x180,%r8d
call   1040 <LEGACY_passwordWrite@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1208 <main+0xc8>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <LEGACY_strError@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xe21(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120f <main+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1195 <main+0x55>
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xeb6(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    $0x180,%r8d
call   1040 <LEGACY_passwordWrite@plt>
test   %eax,%eax
je     11b4 <main+0x74>
mov    0x2e62(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <LEGACY_strError@plt>
lea    0xe8a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
jmp    11a8 <main+0x68>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe58(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11b6 <main+0x76>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <id> <pwd>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [11 x i8] c"ERROR: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
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 %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %35
15: ; preds = %2
%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 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @LEGACY_passwordWrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %21, i32 %25, i32 384)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %15
%30 = load i32, i32* @stderr
%31 = load i32, i32* %6
%32 = call i8* @LEGACY_strError(i32 %31)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %32)
store i32 1, i32* %3
br label %35
34: ; preds = %15
store i32 0, i32* %3
br label %35
35: ; preds = %34, %29, %9
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <id> <pwd>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [11 x i8] c"ERROR: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %20
8: ; preds = %2
%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 i32 @strlen(i8* %12)
%14 = tail call i32 @LEGACY_passwordWrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %12, i32 %13, i32 384)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = tail call i8* @LEGACY_strError(i32 %14)
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %8, %16, %4
%21 = phi i32 [ 1, %4 ], [ 1, %16 ], [ 0, %8 ]
ret i32 %21
}