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

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
scalar_t__ strlen(char *);
scalar_t__ xrealloc(char *, int);
char *get_line(FILE *fp) {
  char s[512], *line, *cp;
  int len = 0, size = 0, l;
  line = NULL;
  do {
    if (fgets(s, 512, fp) == NULL)
      break;
    cp = strchr(s, '\n');
    if (cp != NULL)
      *cp = '\0';
    l = len + (int)strlen(s);
    if (l + 1 > size) {
      size = (int)((l + 1) * 1.2);
      line = (char *)xrealloc(line, size * sizeof(char));
    }
    strcat(line + len, s);
    len = l;
  } while (cp == NULL);
  return line;
}


x86 assembly (clang, -O0):
<get_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x224(%rbp)
movl   $0x0,-0x228(%rbp)
movq   $0x0,-0x218(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11a2 <get_line+0x52>
jmp    128a <get_line+0x13a>
lea    -0x210(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x220(%rbp)
je     11d2 <get_line+0x82>
mov    -0x220(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x224(%rbp),%eax
mov    %eax,-0x230(%rbp)
lea    -0x210(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x230(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x22c(%rbp)
mov    -0x22c(%rbp),%eax
add    $0x1,%eax
cmp    -0x228(%rbp),%eax
jle    1253 <get_line+0x103>
mov    -0x22c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xddb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x228(%rbp)
mov    -0x218(%rbp),%rdi
movslq -0x228(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1050 <xrealloc@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
movslq -0x224(%rbp),%rax
add    %rax,%rdi
lea    -0x210(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x22c(%rbp),%eax
mov    %eax,-0x224(%rbp)
cmpq   $0x0,-0x220(%rbp)
je     117e <get_line+0x2e>
mov    -0x218(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdi,0x8(%rsp)
xor    %r14d,%r14d
lea    0x10(%rsp),%r15
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1196 <get_line+0x46>
cs nopw 0x0(%rax,%rax,1)
movslq %r14d,%rdi
add    %r12,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %ebp,%r14d
test   %rbx,%rbx
jne    11ff <get_line+0xaf>
mov    %r15,%rdi
mov    $0x200,%esi
mov    0x8(%rsp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11ff <get_line+0xaf>
mov    %r15,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c5 <get_line+0x75>
movb   $0x0,(%rbx)
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbp
add    %r14d,%ebp
cmp    %r13d,%ebp
jl     1180 <get_line+0x30>
lea    0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe16(%rip),%xmm0
cvttsd2si %xmm0,%r13d
mov    %r12,%rdi
mov    %r13d,%esi
call   1050 <xrealloc@plt>
mov    %rax,%r12
jmp    1180 <get_line+0x30>
mov    %r12,%rax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_line(i32* %0) {
%2 = alloca i32*
%3 = alloca [512 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %4
br label %9
9: ; preds = %53, %1
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = call i32* @fgets(i8* %10, i32 512, i32* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
br label %56
15: ; preds = %9
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%17 = call i8* @strchr(i8* %16, i8 signext 10)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i8*, i8** %5
store i8 0, i8* %21
br label %22
22: ; preds = %20, %15
%23 = load i32, i32* %6
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%25 = call i64 @strlen(i8* %24)
%26 = trunc i64 %25 to i32
%27 = add nsw i32 %23, %26
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = load i32, i32* %7
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %45
32: ; preds = %22
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
%35 = sitofp i32 %34 to double
%36 = fmul double %35, 1.200000e+00
%37 = fptosi double %36 to i32
store i32 %37, i32* %7
%38 = load i8*, i8** %4
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 1
%42 = trunc i64 %41 to i32
%43 = call i64 @xrealloc(i8* %38, i32 %42)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %4
br label %45
45: ; preds = %32, %22
%46 = load i8*, i8** %4
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%51 = call i32 @strcat(i8* %49, i8* %50)
%52 = load i32, i32* %8
store i32 %52, i32* %6
br label %53
53: ; preds = %45
%54 = load i8*, i8** %5
%55 = icmp eq i8* %54, null
br i1 %55, label %9, label %56
56: ; preds = %53, %14
%57 = load i8*, i8** %4
ret i8* %57
}

LLVM IR (-O2):
define i8* @get_line(i32* nocapture %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %26, %1
%5 = phi i32 [ 0, %1 ], [ %17, %26 ]
%6 = phi i32 [ 0, %1 ], [ %27, %26 ]
%7 = phi i8* [ null, %1 ], [ %28, %26 ]
%8 = call i32* @fgets(i8* %3, i32 512, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %32, label %10
10: ; preds = %4
%11 = call i8* @strchr(i8* %3, i8 signext 10)
%12 = icmp eq i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10
store i8 0, i8* %11
br label %14
14: ; preds = %13, %10
%15 = call i64 @strlen(i8* %3)
%16 = trunc i64 %15 to i32
%17 = add nsw i32 %5, %16
%18 = icmp slt i32 %17, %6
br i1 %18, label %26, label %19
19: ; preds = %14
%20 = add nsw i32 %17, 1
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 1.200000e+00
%23 = fptosi double %22 to i32
%24 = call i64 @xrealloc(i8* %7, i32 %23)
%25 = inttoptr i64 %24 to i8*
br label %26
26: ; preds = %19, %14
%27 = phi i32 [ %23, %19 ], [ %6, %14 ]
%28 = phi i8* [ %25, %19 ], [ %7, %14 ]
%29 = sext i32 %5 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
%31 = call i32 @strcat(i8* %30, i8* %3)
br i1 %12, label %4, label %32
32: ; preds = %4, %26
%33 = phi i8* [ %7, %4 ], [ %28, %26 ]
ret i8* %33
}