#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*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int get_next_line(FILE *f, char *c) {
  char *str, string[200];
  int len;
  do {
    str = string;
    if (!fgets(str, 200, f)) {
      ;
      goto error;
    }
    len = strlen(str);
    while (len >= 1 && isspace(str[len - 1]))
      str[--len] = 0;
    while (isspace(*str))
      str++;
  } while (strlen(str) == 0 || *str == '#');
  strcpy(c, str);
  return 1;
error:
  return 0;
}


x86 assembly (clang, -O0):
<get_next_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    117e <get_next_line+0x3e>
jmp    1281 <get_next_line+0x141>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xf4(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0xf4(%rbp)
mov    %al,-0xf5(%rbp)
jl     11c8 <get_next_line+0x88>
mov    -0x20(%rbp),%rax
mov    -0xf4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xf5(%rbp)
mov    -0xf5(%rbp),%al
test   $0x1,%al
jne    11db <get_next_line+0x9b>
jmp    11fa <get_next_line+0xba>
mov    -0x20(%rbp),%rax
mov    -0xf4(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xf4(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    118d <get_next_line+0x4d>
jmp    11ff <get_next_line+0xbf>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     1226 <get_next_line+0xe6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11ff <get_next_line+0xbf>
jmp    122b <get_next_line+0xeb>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0xf6(%rbp)
je     125a <get_next_line+0x11a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0xf6(%rbp)
mov    -0xf6(%rbp),%al
test   $0x1,%al
jne    1153 <get_next_line+0x13>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1288 <get_next_line+0x148>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
xor    %r15d,%r15d
test   %eax,%eax
je     122a <get_next_line+0xea>
mov    %rbx,0x8(%rsp)
lea    0xf(%rsp),%r13
lea    0x10(%rsp),%rbp
jmp    11a8 <get_next_line+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    $0xc8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     122a <get_next_line+0xea>
mov    %rbp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e4 <get_next_line+0xa4>
mov    %eax,%ebx
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%r14d
movsbl 0x10(%rsp,%r14,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11e4 <get_next_line+0xa4>
movb   $0x0,0x10(%rsp,%r14,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11c0 <get_next_line+0x80>
mov    %r13,%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    11f0 <get_next_line+0xb0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1190 <get_next_line+0x50>
cmpb   $0x23,(%rbx)
je     1190 <get_next_line+0x50>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_next_line(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [200 x i8]
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
br label %9
9: ; preds = %58, %2
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i32*, i32** %4
%13 = call i32 @fgets(i8* %11, i32 200, i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %9
br label %64
16: ; preds = %9
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %8
br label %19
19: ; preds = %33, %16
%20 = load i32, i32* %8
%21 = icmp sge i32 %20, 1
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i8*, i8** %6
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i8, i8* %27
%29 = call i64 @isspace(i8 signext %28)
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %22, %19
%32 = phi i1 [ false, %19 ], [ %30, %22 ]
br i1 %32, label %33, label %39
33: ; preds = %31
%34 = load i8*, i8** %6
%35 = load i32, i32* %8
%36 = add nsw i32 %35, -1
store i32 %36, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 0, i8* %38
br label %19
39: ; preds = %31
br label %40
40: ; preds = %45, %39
%41 = load i8*, i8** %6
%42 = load i8, i8* %41
%43 = call i64 @isspace(i8 signext %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %6
br label %40
48: ; preds = %40
br label %49
49: ; preds = %48
%50 = load i8*, i8** %6
%51 = call i32 @strlen(i8* %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %58, label %53
53: ; preds = %49
%54 = load i8*, i8** %6
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 35
br label %58
58: ; preds = %53, %49
%59 = phi i1 [ true, %49 ], [ %57, %53 ]
br i1 %59, label %9, label %60
60: ; preds = %58
%61 = load i8*, i8** %5
%62 = load i8*, i8** %6
%63 = call i32 @strcpy(i8* %61, i8* %62)
store i32 1, i32* %3
br label %65
64: ; preds = %15
store i32 0, i32* %3
br label %65
65: ; preds = %64, %60
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
define i32 @get_next_line(i32* nocapture %0, i8* %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = call i32 @fgets(i8* %4, i32 200, i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %40, label %7
7: ; preds = %2, %35
%8 = call i32 @strlen(i8* %4)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %20
%13 = phi i64 [ %11, %10 ], [ %14, %20 ]
%14 = add nsw i64 %13, -1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %12
store i8 0, i8* %16
%21 = icmp ugt i64 %13, 1
br i1 %21, label %12, label %22
22: ; preds = %12, %20, %7
br label %23
23: ; preds = %22, %23
%24 = phi i8* [ %28, %23 ], [ %4, %22 ]
%25 = load i8, i8* %24
%26 = call i64 @isspace(i8 signext %25)
%27 = icmp eq i64 %26, 0
%28 = getelementptr inbounds i8, i8* %24, i64 1
br i1 %27, label %29, label %23
29: ; preds = %23
%30 = call i32 @strlen(i8* %24)
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i8, i8* %24
%34 = icmp eq i8 %33, 35
br i1 %34, label %35, label %38
35: ; preds = %32, %29
%36 = call i32 @fgets(i8* %4, i32 200, i32* %0)
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %7
38: ; preds = %32
%39 = call i32 @strcpy(i8* %1, i8* %24)
br label %40
40: ; preds = %35, %2, %38
%41 = phi i32 [ 1, %38 ], [ 0, %2 ], [ 0, %35 ]
ret i32 %41
}