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

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  char line[256];
  int ii;
  printf("Enter string to Echo: ");
  if (fgets(line, sizeof(line), stdin)) {
    printf("Echo: %s\n", line);
  }
  printf("Enter integer to Echo: ");
  if (fgets(line, sizeof(line), stdin)) {
    if (1 == sscanf(line, "%d", &ii)) {
      printf("Echo: %d\n", ii);
    } else {
      printf("Could not convert to integer.\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1189 <main+0x59>
lea    -0x110(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e43(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1210 <main+0xe0>
lea    -0x110(%rbp),%rdi
lea    0xe70(%rip),%rsi
lea    -0x114(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    11fd <main+0xcd>
mov    -0x114(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xdb>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1210 <main+0xe0>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x110,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e8b(%rip),%rbx
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1186 <main+0x46>
lea    0xe9d(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11e5 <main+0xa5>
lea    0xe88(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11d9 <main+0x99>
mov    0xc(%rsp),%esi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e5 <main+0xa5>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter string to Echo: \00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"Echo: %s\0A\00"
@.str.2 = [24 x i8] c"Enter integer to Echo: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"Echo: %d\0A\00"
@.str.5 = [31 x i8] c"Could not convert to integer.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %5, i32 256, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i64 @fgets(i8* %14, i32 256, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%21 = icmp eq i32 1, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %27
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
br label %28
28: ; preds = %27, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter string to Echo: \00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"Echo: %s\0A\00"
@.str.2 = [24 x i8] c"Enter integer to Echo: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"Echo: %d\0A\00"
@str = [30 x i8] c"Could not convert to integer.\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %3, i32 256, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %11
11: ; preds = %9, %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %3, i32 256, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %11
%17 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %24
22: ; preds = %16
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %19, %22, %11
ret i32 0
}