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

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
unsigned int strlen(char *);
int /*<<< orphan*/ system(char *);
int main() {
  char myPwd[20];
  unsigned int i;
  fgets(myPwd, sizeof(myPwd), stdin);
  for (i = 0; i < strlen(myPwd); i++)
    if (myPwd[i] == '\r' || myPwd[i] == '\n')
      myPwd[i] = '\0';
  if (strcmp(myPwd, "test") == 0) {
    system("cmd.exe");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1050 <fgets@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jae    11c6 <main+0x86>
mov    -0x24(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xd,%eax
je     11ab <main+0x6b>
mov    -0x24(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11b3 <main+0x73>
mov    -0x24(%rbp),%eax
movb   $0x0,-0x20(%rbp,%rax,1)
jmp    11b8 <main+0x78>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116d <main+0x2d>
lea    -0x20(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <main+0xac>
lea    0xe1e(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11a5 <main+0x65>
xor    %ebx,%ebx
mov    %rsp,%r14
jmp    1197 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jae    11a5 <main+0x65>
movzbl (%rsp,%rbx,1),%eax
cmp    $0xd,%al
je     1180 <main+0x40>
cmp    $0xa,%al
je     1180 <main+0x40>
jmp    1184 <main+0x44>
lea    0xe54(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11c5 <main+0x85>
lea    0xe45(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"test\00"
@.str.1 = [8 x i8] c"cmd.exe\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 20, i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %3
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp ult i32 %8, %10
br i1 %11, label %12, label %34
12: ; preds = %7
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 13
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = load i32, i32* %3
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %19, %12
%27 = load i32, i32* %3
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %26, %19
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add i32 %32, 1
store i32 %33, i32* %3
br label %7
34: ; preds = %7
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"test\00"
@.str.1 = [8 x i8] c"cmd.exe\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 20, i32 %3)
%5 = call i32 @strlen(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %0, %12
%8 = phi i64 [ %13, %12 ], [ 0, %0 ]
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %12 [
i8 13, label %11
i8 10, label %11
]
11: ; preds = %7, %7
store i8 0, i8* %9
br label %12
12: ; preds = %7, %11
%13 = add nuw nsw i64 %8, 1
%14 = call i32 @strlen(i8* %2)
%15 = zext i32 %14 to i64
%16 = icmp ult i64 %13, %15
br i1 %16, label %7, label %17
17: ; preds = %12, %0
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
ret i32 0
}