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

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ chop(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ is_empty(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int main() {
  char buf[512];
  printf("Enter something: ");
  fgets(buf, sizeof(buf), stdin);
  chop(buf);
  if (!is_empty(buf)) {
    printf("You entered: %s\n", buf);
  } else {
    puts("You didn't enter anything.");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1070 <fgets@plt>
lea    -0x210(%rbp),%rdi
call   1050 <chop@plt>
lea    -0x210(%rbp),%rdi
call   1060 <is_empty@plt>
cmp    $0x0,%eax
jne    11c5 <main+0x75>
lea    -0x210(%rbp),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d1 <main+0x81>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <chop@plt>
mov    %rbx,%rdi
call   1060 <is_empty@plt>
test   %eax,%eax
je     11a1 <main+0x51>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
jmp    11b2 <main+0x62>
lea    0xe6a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter something: \00"
@stdin = global i32 0
@.str.1 = [17 x i8] c"You entered: %s\0A\00"
@.str.2 = [27 x i8] c"You didn't enter anything.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 512, i32 %5)
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%8 = call i32 @chop(i8* %7)
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%10 = call i32 @is_empty(i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %0
%16 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter something: \00"
@stdin = global i32 0
@.str.1 = [17 x i8] c"You entered: %s\0A\00"
@.str.2 = [27 x i8] c"You didn't enter anything.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 512, i32 %4)
%6 = call i32 @chop(i8* %2)
%7 = call i32 @is_empty(i8* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}