#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char buffer[40];
  char password[] = "secret";
  int p = 0;
  int match = 1;
  char *ptrBuffer = buffer;
  char *ptrPassword = password;
  scanf("%s", buffer);
  while (*ptrPassword != '\0') {
    if (*ptrPassword != *ptrBuffer) {
      match = 0;
    }
    ptrBuffer++;
    ptrPassword++;
  }
  if (match == 1)
    printf("success");
  else
    printf("login incorrect");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x37(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x33(%rbp)
mov    0xebd(%rip),%al
mov    %al,-0x31(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x37(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c4 <main+0xa4>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
mov    -0x48(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a7 <main+0x87>
movl   $0x0,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    117a <main+0x5a>
cmpl   $0x1,-0x40(%rbp)
jne    11df <main+0xbf>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
jmp    11eb <main+0xcb>
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movl   $0x746572,0xb(%rsp)
movl   $0x72636573,0x8(%rsp)
72
lea    0xecc(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%eax
mov    $0x73,%cl
xor    %esi,%esi
xor    %edx,%edx
cmp    0x10(%rsp,%rdx,1),%cl
cmovne %esi,%eax
movzbl 0x9(%rsp,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1150 <main+0x30>
cmp    $0x1,%eax
lea    0xe9c(%rip),%rax
lea    0xe9d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.password = [7 x i8] c"secret\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [16 x i8] c"login incorrect\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [7 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
%8 = bitcast [7 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 1, i32* %5
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
store i8* %9, i8** %6
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
store i8* %10, i8** %7
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %27, %0
%14 = load i8*, i8** %7
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %21, %24
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 0, i32* %5
br label %27
27: ; preds = %26, %18
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
br label %13
32: ; preds = %13
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %39
37: ; preds = %32
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
ret i32 0
}

LLVM IR (-O2):
@__const.main.password = [7 x i8] c"secret\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [16 x i8] c"login incorrect\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %6
6: ; preds = %0, %6
%7 = phi i8 [ %16, %6 ], [ 115, %0 ]
%8 = phi i8* [ %15, %6 ], [ %4, %0 ]
%9 = phi i8* [ %14, %6 ], [ %3, %0 ]
%10 = phi i32 [ %13, %6 ], [ 1, %0 ]
%11 = load i8, i8* %9
%12 = icmp eq i8 %7, %11
%13 = select i1 %12, i32 %10, i32 0
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = icmp eq i32 %13, 1
%20 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0)
%21 = call i32 @printf(i8* dereferenceable(1) %20)
ret i32 0
}