#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*/ isspace(char const);
int /*<<< orphan*/ output_char(char const);
int /*<<< orphan*/ output_header(char const);
void output_until_space(const char *str, int header) {
  while (!isspace(*str) && *str != '\0') {
    if (!header)
      output_char(*str);
    else
      output_header(*str);
    str++;
  }
}


x86 assembly (clang, -O0):
<output_until_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
jne    116b <output_until_space+0x3b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117b <output_until_space+0x4b>
jmp    11b3 <output_until_space+0x83>
cmpl   $0x0,-0xc(%rbp)
jne    1196 <output_until_space+0x66>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <output_char@plt>
jmp    11a2 <output_until_space+0x72>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <output_header@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113f <output_until_space+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_until_space>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <isspace@plt>
test   %eax,%eax
je     114b <output_until_space+0x1b>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
add    $0x1,%rbx
jmp    1175 <output_until_space+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1040 <output_char@plt>
movsbl (%rbx),%edi
call   1050 <isspace@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1144 <output_until_space+0x14>
movzbl -0x1(%rbx),%eax
test   %al,%al
je     1144 <output_until_space+0x14>
movsbl %al,%edi
test   %ebp,%ebp
je     1160 <output_until_space+0x30>
call   1030 <output_header@plt>
jmp    1165 <output_until_space+0x35>

LLVM IR (-O0):
define void @output_until_space(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %28, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i32 @isspace(i8 signext %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %31
17: ; preds = %15
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = call i32 @output_char(i8 signext %22)
br label %28
24: ; preds = %17
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i32 @output_header(i8 signext %26)
br label %28
28: ; preds = %24, %20
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
br label %5
31: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @output_until_space(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = tail call i32 @isspace(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br label %8
8: ; preds = %6, %17
%9 = phi i8* [ %0, %6 ], [ %18, %17 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %8
br i1 %7, label %13, label %15
13: ; preds = %12
%14 = tail call i32 @output_char(i8 signext %10)
br label %17
15: ; preds = %12
%16 = tail call i32 @output_header(i8 signext %10)
br label %17
17: ; preds = %15, %13
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = load i8, i8* %18
%20 = tail call i32 @isspace(i8 signext %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %8, label %22
22: ; preds = %8, %17, %2
ret void
}