#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(void) {
  char *A;
label_10:
  printf("%s\n", "What's your name?");
label_20:
  A = malloc(sizeof(char) * 50);
  fgets(A, 50, stdin);
  if (A[strlen(A) - 1] == '\n') {
    A[strlen(A) - 1] = '\0';
  }
label_30:
  printf("%s %s\n", A, "is awesome!");
label_40:
  free(A);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1060 <fgets@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11e4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11e9 <main+0x99>
mov    -0x10(%rbp),%rsi
lea    0xe1e(%rip),%rdi
lea    0xe1e(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xebd(%rip),%rdi
lea    0xea1(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    11a9 <main+0x59>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe62(%rip),%rdi
lea    0xe62(%rip),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"What's your name?\00"
@stdin = global i32 0
@.str.2 = [7 x i8] c"%s %s\0A\00"
@.str.3 = [12 x i8] c"is awesome!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0
%4 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %3
%6 = call i8* @malloc(i32 50)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 50, i32 %8)
%10 = load i8*, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %26
19: ; preds = %5
%20 = load i8*, i8** %2
%21 = load i8*, i8** %2
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %19, %5
br label %27
27: ; preds = %26
%28 = load i8*, i8** %2
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %27
%31 = load i8*, i8** %2
%32 = call i32 @free(i8* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"What's your name?\00"
@stdin = global i32 0
@.str.2 = [7 x i8] c"%s %s\0A\00"
@.str.3 = [12 x i8] c"is awesome!\00"
define i32 @main() {
%1 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* %2, i32 50, i32 %3)
%5 = tail call i32 @strlen(i8* %2)
%6 = add nsw i32 %5, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = tail call i32 @strlen(i8* %2)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %2, i64 %14
store i8 0, i8* %15
br label %16
16: ; preds = %0, %11
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @free(i8* %2)
ret i32 0
}