#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*/ buff;

/* Variables and functions */
int /*<<< orphan*/ gets(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char *getter;
  char buff[2];
  int pass = 0;
  getter = (char *)malloc(sizeof(char) * 6);
  printf("\n Enter the password : \n");
  printf("%lu + %s \n", sizeof(buff), buff);
  gets(getter);
  strcpy(buff, getter);
  printf("============\nPassword is %d \n============\n", pass);
  printf("%lu + %s \n", sizeof(buff), buff);
  printf("%lu + %s\n", sizeof(buff), buff);
  if (strcmp(buff, "123456")) {
    printf("\n Wrong Password \n");
  } else {
    printf("\n Correct Password \n");
    pass = 1;
  }
  if (pass) {
    printf("\n Root privileges given to the user \n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdx
lea    0xe8c(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x12(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdx
lea    0xe4e(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     121b <main+0xcb>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1230 <main+0xe0>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1248 <main+0xf8>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x6,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
lea    0xe77(%rip),%r15
lea    0xe(%rsp),%r14
mov    $0x2,%esi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe51(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%esi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x2,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4e(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1208 <main+0xa8>
lea    0xe92(%rip),%rdi
jmp    121b <main+0xbb>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0A Enter the password : \0A\00"
@.str.1 = [11 x i8] c"%lu + %s \0A\00"
@.str.2 = [43 x i8] c"============\0APassword is %d \0A============\0A\00"
@.str.3 = [10 x i8] c"%lu + %s\0A\00"
@.str.4 = [7 x i8] c"123456\00"
@.str.5 = [19 x i8] c"\0A Wrong Password \0A\00"
@.str.6 = [21 x i8] c"\0A Correct Password \0A\00"
@.str.7 = [38 x i8] c"\0A Root privileges given to the user \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [2 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i64 @malloc(i32 6)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 2, i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 2, i8* %17)
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 2, i8* %19)
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %28
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %4
br label %28
28: ; preds = %26, %24
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"%lu + %s \0A\00"
@.str.2 = [43 x i8] c"============\0APassword is %d \0A============\0A\00"
@.str.3 = [10 x i8] c"%lu + %s\0A\00"
@.str.4 = [7 x i8] c"123456\00"
@str = [24 x i8] c"\0A Enter the password : \00"
@str.8 = [20 x i8] c"\0A Correct Password \00"
@str.9 = [37 x i8] c"\0A Root privileges given to the user \00"
@str.10 = [18 x i8] c"\0A Wrong Password \00"
define i32 @main() {
%1 = alloca [2 x i8]
%2 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%3 = tail call i64 @malloc(i32 6)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 2, i8* %2)
%7 = call i32 @gets(i8* %4)
%8 = call i32 @strcpy(i8* %2, i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 0)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 2, i8* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 2, i8* %2)
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
br label %16
16: ; preds = %0, %14
%17 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %0 ]
%18 = call i32 @puts(i8* dereferenceable(1) %17)
ret i32 0
}