#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*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char buffer[8];
  int x;
  printf("Format command: ");
  fgets(buffer, 8, stdin);
  for (x = 0; x < 8; x++) {
    if (buffer[x] == '\n') {
      buffer[x] = '\0';
      break;
    }
  }
  printf("The value is '");
  printf(buffer, 0x1234);
  printf("'\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1040 <fgets@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1198 <main+0x78>
movslq -0x10(%rbp),%rax
movsbl -0xc(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1185 <main+0x65>
movslq -0x10(%rbp),%rax
movb   $0x0,-0xc(%rbp,%rax,1)
jmp    1198 <main+0x78>
jmp    118a <main+0x6a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <main+0x3b>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    $0x1234,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e9c(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
call   1050 <fgets@plt>
cmpb   $0xa,0x8(%rsp)
je     11b8 <main+0x88>
mov    $0x1,%ebx
cmpb   $0xa,0x9(%rsp)
je     11b8 <main+0x88>
mov    $0x2,%ebx
cmpb   $0xa,0xa(%rsp)
je     11b8 <main+0x88>
mov    $0x3,%ebx
cmpb   $0xa,0xb(%rsp)
je     11b8 <main+0x88>
mov    $0x4,%ebx
cmpb   $0xa,0xc(%rsp)
je     11b8 <main+0x88>
mov    $0x5,%ebx
cmpb   $0xa,0xd(%rsp)
je     11b8 <main+0x88>
mov    $0x6,%ebx
cmpb   $0xa,0xe(%rsp)
je     11b8 <main+0x88>
mov    $0x7,%ebx
cmpb   $0xa,0xf(%rsp)
jne    11bd <main+0x8d>
movb   $0x0,0x8(%rsp,%rbx,1)
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
mov    $0x1234,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Format command: \00"
@stdin = global i32 0
@.str.1 = [15 x i8] c"The value is '\00"
@.str.2 = [3 x i8] c"'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 8, i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
br label %26
22: ; preds = %11
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %18, %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* %28, i32 4660)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Format command: \00"
@stdin = global i32 0
@.str.1 = [15 x i8] c"The value is '\00"
@str = [2 x i8] c"'\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 8, i32 %4)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %11
8: ; preds = %35, %31, %27, %23, %19, %15, %11, %0
%9 = phi i64 [ 0, %0 ], [ 1, %11 ], [ 2, %15 ], [ 3, %19 ], [ 4, %23 ], [ 5, %27 ], [ 6, %31 ], [ 7, %35 ]
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
br label %39
11: ; preds = %0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %8, label %15
15: ; preds = %11
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 2
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %8, label %19
19: ; preds = %15
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 3
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %8, label %23
23: ; preds = %19
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 4
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 10
br i1 %26, label %8, label %27
27: ; preds = %23
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 5
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 10
br i1 %30, label %8, label %31
31: ; preds = %27
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 6
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 10
br i1 %34, label %8, label %35
35: ; preds = %31
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 7
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 10
br i1 %38, label %8, label %39
39: ; preds = %35, %8
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* %2, i32 4660)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}