#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void good_echo() {
  char buffer[256];
  printf("Input:\t");
  if (fgets(buffer, 256, stdin) != NULL) {
    printf("Output:\t");
    fputs(buffer, stdout);
  } else {
    printf("Don't panic! Something is wrong. \n");
  }
}


x86 assembly (clang, -O0):
<good_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    -0x100(%rbp),%rdi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1191 <good_echo+0x61>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
lea    -0x100(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
jmp    119d <good_echo+0x6d>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<good_echo>:
sub    $0x108,%rsp
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1193 <good_echo+0x53>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1050 <fputs@plt>
add    $0x108,%rsp
ret
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Input:\09\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"Output:\09\00"
@stdout = global i32 0
@.str.2 = [35 x i8] c"Don't panic! Something is wrong. \0A\00"
define void @good_echo() {
%1 = alloca [256 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %3, i32 256, i32 %4)
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%10 = load i32, i32* @stdout
%11 = call i32 @fputs(i8* %9, i32 %10)
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"Input:\09\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"Output:\09\00"
@stdout = global i32 0
@str = [34 x i8] c"Don't panic! Something is wrong. \00"
define void @good_echo() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %2, i32 256, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = call i32 @fputs(i8* %2, i32 %9)
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
ret void
}