#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*/ get_next_line(int /*<<< orphan*/ *, char *);
scalar_t__ isspace(char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int next_line_str(FILE *f, char *tag, char *out) {
  char str[256], *t_str;
  if (!get_next_line(f, str))
    goto error;
  t_str = strtok(str, " ");
  if (!t_str || strcmp(t_str, tag))
    goto error;
  t_str = strtok(NULL, "\n");
  if (!t_str)
    goto error;
  {
    while (isspace(*(t_str)))
      (t_str)++;
  };
  strcpy(out, t_str);
  return 1;
error:
  return 0;
}


x86 assembly (clang, -O0):
<next_line_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1070 <get_next_line@plt>
cmp    $0x0,%eax
jne    1185 <next_line_str+0x35>
jmp    1247 <next_line_str+0xf7>
lea    -0x120(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     11c7 <next_line_str+0x77>
mov    -0x128(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11cc <next_line_str+0x7c>
jmp    1247 <next_line_str+0xf7>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    11f6 <next_line_str+0xa6>
jmp    1247 <next_line_str+0xf7>
jmp    11fb <next_line_str+0xab>
mov    -0x128(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     122b <next_line_str+0xdb>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    11fb <next_line_str+0xab>
mov    -0x20(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    124e <next_line_str+0xfe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_line_str>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rsp,%rsi
call   1070 <get_next_line@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     11e3 <next_line_str+0x93>
lea    0xe86(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11e3 <next_line_str+0x93>
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e3 <next_line_str+0x93>
lea    0xe64(%rip),%rsi
xor    %r12d,%r12d
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     11e3 <next_line_str+0x93>
mov    %rax,%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    11c0 <next_line_str+0x70>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @next_line_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [256 x i8]
%9 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i32*, i32** %5
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%12 = call i32 @get_next_line(i32* %10, i8* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %3
br label %44
15: ; preds = %3
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i8*, i8** %9
%22 = load i8*, i8** %6
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20, %15
br label %44
26: ; preds = %20
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %9
%28 = load i8*, i8** %9
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %26
br label %44
31: ; preds = %26
br label %32
32: ; preds = %37, %31
%33 = load i8*, i8** %9
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %9
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %9
br label %32
40: ; preds = %32
%41 = load i8*, i8** %7
%42 = load i8*, i8** %9
%43 = call i32 @strcpy(i8* %41, i8* %42)
store i32 1, i32* %4
br label %45
44: ; preds = %30, %25, %14
store i32 0, i32* %4
br label %45
45: ; preds = %44, %40
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @next_line_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @get_next_line(i32* %0, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %3
%9 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %25, label %11
11: ; preds = %8
%12 = call i64 @strcmp(i8* %9, i8* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %25, label %17
17: ; preds = %14, %17
%18 = phi i8* [ %22, %17 ], [ %15, %14 ]
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 signext %19)
%21 = icmp eq i64 %20, 0
%22 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %21, label %23, label %17
23: ; preds = %17
%24 = call i32 @strcpy(i8* %2, i8* %18)
br label %25
25: ; preds = %3, %11, %8, %14, %23
%26 = phi i32 [ 1, %23 ], [ 0, %14 ], [ 0, %8 ], [ 0, %11 ], [ 0, %3 ]
ret i32 %26
}