#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 */
struct __instr {
  int dummy;
};

/* Variables and functions */
int EOF;
int __instr_getc(struct __instr *);
int /*<<< orphan*/ __instr_ungetc(struct __instr *, int);
scalar_t__ isspace(int);
int __scanf_conv_str(struct __instr *_is, char *out) {
  while (1) {
    int c = __instr_getc(_is);
    if (c == EOF) {
      break;
    };
    if (isspace(c)) {
      __instr_ungetc(_is, c);
      break;
    };
    if (out != NULL)
      *out++ = c;
  };
  if (out != NULL)
    *out = 0;
  return 0;
}


x86 assembly (clang, -O0):
<__scanf_conv_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <__instr_getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
jne    1163 <__scanf_conv_str+0x33>
jmp    11ac <__scanf_conv_str+0x7c>
mov    -0x14(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1186 <__scanf_conv_str+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <__instr_ungetc@plt>
jmp    11ac <__scanf_conv_str+0x7c>
cmpq   $0x0,-0x10(%rbp)
je     11a7 <__scanf_conv_str+0x77>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1140 <__scanf_conv_str+0x10>
cmpq   $0x0,-0x10(%rbp)
je     11be <__scanf_conv_str+0x8e>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__scanf_conv_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1050 <__instr_getc@plt>
mov    0x2e9f(%rip),%r15
cmp    (%r15),%eax
je     1195 <__scanf_conv_str+0x65>
mov    %eax,%ebp
jmp    1176 <__scanf_conv_str+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %bpl,(%rbx)
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <__instr_getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     1195 <__scanf_conv_str+0x65>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    118b <__scanf_conv_str+0x5b>
test   %rbx,%rbx
jne    1160 <__scanf_conv_str+0x30>
xor    %ebx,%ebx
jmp    1167 <__scanf_conv_str+0x37>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <__instr_ungetc@plt>
test   %rbx,%rbx
je     119d <__scanf_conv_str+0x6d>
movb   $0x0,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.__instr = type { i32 }
@EOF = global i32 0
define i32 @__scanf_conv_str(%struct.__instr* %0, i8* %1) {
%3 = alloca %struct.__instr*
%4 = alloca i8*
%5 = alloca i32
store %struct.__instr* %0, %struct.__instr** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %2, %29
%7 = load %struct.__instr*, %struct.__instr** %3
%8 = call i32 @__instr_getc(%struct.__instr* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %6
br label %30
13: ; preds = %6
%14 = load i32, i32* %5
%15 = call i64 @isspace(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load %struct.__instr*, %struct.__instr** %3
%19 = load i32, i32* %5
%20 = call i32 @__instr_ungetc(%struct.__instr* %18, i32 %19)
br label %30
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %5
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
store i8 %26, i8* %27
br label %29
29: ; preds = %24, %21
br label %6
30: ; preds = %17, %12
%31 = load i8*, i8** %4
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i8*, i8** %4
store i8 0, i8* %34
br label %35
35: ; preds = %33, %30
ret i32 0
}

LLVM IR (-O2):
%struct.__instr = type { i32 }
@EOF = global i32 0
define i32 @__scanf_conv_str(%struct.__instr* %0, i8* writeonly %1) {
%3 = tail call i32 @__instr_getc(%struct.__instr* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %23, label %6
6: ; preds = %2, %18
%7 = phi i32 [ %20, %18 ], [ %3, %2 ]
%8 = phi i8* [ %19, %18 ], [ %1, %2 ]
%9 = tail call i64 @isspace(i32 %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @__instr_ungetc(%struct.__instr* %0, i32 %7)
br label %23
13: ; preds = %6
%14 = icmp eq i8* %8, null
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = trunc i32 %7 to i8
%17 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %16, i8* %8
br label %18
18: ; preds = %13, %15
%19 = phi i8* [ %17, %15 ], [ null, %13 ]
%20 = tail call i32 @__instr_getc(%struct.__instr* %0)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %6
23: ; preds = %18, %2, %11
%24 = phi i8* [ %8, %11 ], [ %1, %2 ], [ %19, %18 ]
%25 = icmp eq i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %23
store i8 0, i8* %24
br label %27
27: ; preds = %26, %23
ret i32 0
}