#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 /*<<< orphan*/ free(char *);
char *getpass(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  char *ptr;
  char *pass1;
  char *pass2;
  int i;
  pass1 = NULL;
  pass2 = NULL;
  if (argc < 2) {
  };
  printf("%s:  Changing password for %s\n", argv[0], argv[0]);
  for (i = 0; i < 3; i++) {
    free(pass1);
    free(pass2);
    ptr = getpass("New password: ");
    pass1 = strdup(ptr);
    ptr = getpass("Re-enter new password: ");
    pass2 = strdup(ptr);
    if (!strcmp(pass1, pass2)) {
      i = 3;
    } else {
      printf("passwd(SYSTEM): They don't match; try again.\n");
    };
  };
  if (strcmp(pass1, pass2)) {
    printf("passwd(SYSTEM): Too many tries; try again later\n");
    printf("Permission denied\n");
    return (1);
  };
  printf("passwd (SYSTEM): passwd successfully changed for syzdek\n");
  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)
movq   $0x0,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1185 <main+0x35>
jmp    1185 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1242 <main+0xf2>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
lea    0xe54(%rip),%rdi
call   1060 <getpass@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
lea    0xe46(%rip),%rdi
call   1060 <getpass@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <main+0xd1>
movl   $0x3,-0x2c(%rbp)
jmp    122f <main+0xdf>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1234 <main+0xe4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a8 <main+0x58>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1281 <main+0x131>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1296 <main+0x146>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%rdx
lea    0xe91(%rip),%rdi
xor    %r14d,%r14d
mov    %rdx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <free@plt>
xor    %edi,%edi
call   1030 <free@plt>
lea    0xe8e(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
lea    0xe86(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     128c <main+0x12c>
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe30(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
lea    0xe28(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     128c <main+0x12c>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xdd6(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
lea    0xdce(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     128c <main+0x12c>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12b7 <main+0x157>
lea    0xddb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
lea    0xdf9(%rip),%rdi
jmp    12be <main+0x15e>
lea    0xd88(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"%s: Changing password for %s\0A\00"
@.str.1 = [15 x i8] c"New password: \00"
@.str.2 = [24 x i8] c"Re-enter new password: \00"
@.str.3 = [46 x i8] c"passwd(SYSTEM): They don't match; try again.\0A\00"
@.str.4 = [49 x i8] c"passwd(SYSTEM): Too many tries; try again later\0A\00"
@.str.5 = [19 x i8] c"Permission denied\0A\00"
@.str.6 = [57 x i8] c"passwd (SYSTEM): passwd successfully changed for syzdek\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %19)
store i32 0, i32* %9
br label %21
21: ; preds = %43, %13
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %46
24: ; preds = %21
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %8
%28 = call i32 @free(i8* %27)
%29 = call i8* @getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %7
%32 = call i8* @getpass(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = call i8* @strdup(i8* %33)
store i8* %34, i8** %8
%35 = load i8*, i8** %7
%36 = load i8*, i8** %8
%37 = call i64 @strcmp(i8* %35, i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %24
store i32 3, i32* %9
br label %42
40: ; preds = %24
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %39
br label %43
43: ; preds = %42
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %21
46: ; preds = %21
%47 = load i8*, i8** %7
%48 = load i8*, i8** %8
%49 = call i64 @strcmp(i8* %47, i8* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %56
56: ; preds = %54, %51
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [31 x i8] c"%s: Changing password for %s\0A\00"
@.str.1 = [15 x i8] c"New password: \00"
@.str.2 = [24 x i8] c"Re-enter new password: \00"
@str = [56 x i8] c"passwd (SYSTEM): passwd successfully changed for syzdek\00"
@str.7 = [48 x i8] c"passwd(SYSTEM): Too many tries; try again later\00"
@str.8 = [18 x i8] c"Permission denied\00"
@str.9 = [45 x i8] c"passwd(SYSTEM): They don't match; try again.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %3)
%5 = tail call i32 @free(i8* null)
%6 = tail call i32 @free(i8* null)
%7 = tail call i8* @getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i8* @strdup(i8* %7)
%9 = tail call i8* @getpass(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i8* @strdup(i8* %9)
%11 = tail call i64 @strcmp(i8* %8, i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %35, label %13
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.9, i64 0, i64 0))
%15 = tail call i32 @free(i8* %8)
%16 = tail call i32 @free(i8* %10)
%17 = tail call i8* @getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i8* @strdup(i8* %17)
%19 = tail call i8* @getpass(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i8* @strdup(i8* %19)
%21 = tail call i64 @strcmp(i8* %18, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %35, label %23
23: ; preds = %13
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.9, i64 0, i64 0))
%25 = tail call i32 @free(i8* %18)
%26 = tail call i32 @free(i8* %20)
%27 = tail call i8* @getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i8* @strdup(i8* %27)
%29 = tail call i8* @getpass(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%30 = tail call i8* @strdup(i8* %29)
%31 = tail call i64 @strcmp(i8* %28, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %23
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.9, i64 0, i64 0))
br label %35
35: ; preds = %33, %23, %13, %2
%36 = phi i8* [ %8, %2 ], [ %18, %13 ], [ %28, %23 ], [ %28, %33 ]
%37 = phi i8* [ %10, %2 ], [ %20, %13 ], [ %30, %23 ], [ %30, %33 ]
%38 = tail call i64 @strcmp(i8* %36, i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.7, i64 0, i64 0))
br label %42
42: ; preds = %35, %40
%43 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0), %40 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0), %35 ]
%44 = phi i32 [ 1, %40 ], [ 0, %35 ]
%45 = tail call i32 @puts(i8* dereferenceable(1) %43)
ret i32 %44
}