#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 */
char *crypt(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int ac, char *av[]) {
  char *pCrypt;
  (void)ac;
  (void)av;
  if (ac != 2) {
    usage(av[0]);
    return 1;
  }
  pCrypt = crypt(av[1], "ab");
  printf("Project2 : word '%s' is encrypted as '%s'\n", av[1], pCrypt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1168 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    119f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe89(%rip),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1160 <main+0x30>
mov    0x8(%rbx),%rdi
lea    0xebc(%rip),%rsi
call   1030 <crypt@plt>
mov    0x8(%rbx),%rsi
lea    0xeaf(%rip),%rdi
mov    %rax,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ab\00"
@.str.1 = [43 x i8] c"Project2 : word '%s' is encrypted as '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
store i32 1, i32* %3
br label %26
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @crypt(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
store i32 0, i32* %3
br label %26
26: ; preds = %16, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"ab\00"
@.str.1 = [43 x i8] c"Project2 : word '%s' is encrypted as '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %13
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i8* @crypt(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %8
%12 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %10)
br label %13
13: ; preds = %7, %4
%14 = phi i32 [ 1, %4 ], [ 0, %7 ]
ret i32 %14
}