#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*/ encrypt(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strip_linefeed(char *);
int main() {
  char msg[80];
  printf("Type msg to be encrypted (CTRL+D to end)\n");
  while (fgets(msg, 80, stdin)) {
    strip_linefeed(msg);
    encrypt(msg);
    printf("%s\n", msg);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11a7 <main+0x67>
lea    -0x60(%rbp),%rdi
call   1030 <strip_linefeed@plt>
lea    -0x60(%rbp),%rdi
call   1050 <encrypt@plt>
lea    -0x60(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e8e(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11ad <main+0x6d>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <strip_linefeed@plt>
mov    %rbx,%rdi
call   1050 <encrypt@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Type msg to be encrypted (CTRL+D to end)\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %9, %0
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %5, i32 80, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%11 = call i32 @strip_linefeed(i8* %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = call i32 @encrypt(i8* %12)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %4
16: ; preds = %4
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [41 x i8] c"Type msg to be encrypted (CTRL+D to end)\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i64 @fgets(i8* %2, i32 80, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %0, %7
%8 = call i32 @strip_linefeed(i8* %2)
%9 = call i32 @encrypt(i8* %2)
%10 = call i32 @puts(i8* %2)
%11 = load i32, i32* @stdin
%12 = call i64 @fgets(i8* %2, i32 80, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %7, %0
ret i32 0
}