#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char string[256];
  int i;
  printf("Please enter a long string: ");
  fgets(string, 256, stdin);
  for (i = 0; i < 256; i++) {
    if (string[i] == '\n') {
      string[i] = '\0';
      break;
    }
  }
  printf("You entered a very long string, %s", string);
  getchar();
}


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>
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jge    11c9 <main+0x99>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    11b0 <main+0x80>
movslq -0x114(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
jmp    11c9 <main+0x99>
jmp    11b5 <main+0x85>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1174 <main+0x44>
lea    -0x110(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xec1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
xchg   %ax,%ax
cmpb   $0xa,(%rsp,%rbx,1)
je     119a <main+0x6a>
cmpb   $0xa,0x1(%rsp,%rbx,1)
je     118a <main+0x5a>
cmpb   $0xa,0x2(%rsp,%rbx,1)
je     1190 <main+0x60>
cmpb   $0xa,0x3(%rsp,%rbx,1)
je     1196 <main+0x66>
add    $0x4,%rbx
cmp    $0x100,%rbx
jne    1160 <main+0x30>
jmp    11a0 <main+0x70>
add    $0x1,%rbx
jmp    119a <main+0x6a>
add    $0x2,%rbx
jmp    119a <main+0x6a>
add    $0x3,%rbx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe76(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Please enter a long string: \00"
@stdin = global i32 0
@.str.1 = [35 x i8] c"You entered a very long string, %s\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 ([29 x i8], [29 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 i32 @fgets(i8* %5, i32 256, i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [256 x i8], [256 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 [256 x i8], [256 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 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 (...) @getchar()
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [29 x i8] c"Please enter a long string: \00"
@stdin = global i32 0
@.str.1 = [35 x i8] c"You entered a very long string, %s\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 256, i32 %4)
br label %6
6: ; preds = %30, %0
%7 = phi i64 [ 0, %0 ], [ %31, %30 ]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %25, %20, %15, %6
%12 = phi i64 [ %7, %6 ], [ %16, %15 ], [ %21, %20 ], [ %26, %25 ]
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %13
store i8 0, i8* %14
br label %33
15: ; preds = %6
%16 = or i64 %7, 1
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 10
br i1 %19, label %11, label %20
20: ; preds = %15
%21 = or i64 %7, 2
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %11, label %25
25: ; preds = %20
%26 = or i64 %7, 3
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
br i1 %29, label %11, label %30
30: ; preds = %25
%31 = add nuw nsw i64 %7, 4
%32 = icmp eq i64 %31, 256
br i1 %32, label %33, label %6
33: ; preds = %30, %11
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%35 = call i32 (...) @getchar()
ret i32 0
}