#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 EOF;
int getc(int /*<<< orphan*/ *);
int ignore_whitespace(int /*<<< orphan*/ *);
int /*<<< orphan*/ sysbuild_warning(char *);
int read_string(FILE *config_fp, char str[256]) {
  int c;
  int i;
  if ((c = ignore_whitespace(config_fp)) != '"') {
    sysbuild_warning("Failed to find starting quote (\")");
    return 0;
  }
  c = getc(config_fp);
  for (i = 0; c != '"' && c != EOF; i++) {
    str[i] = c;
    c = getc(config_fp);
  }
  str[i] = '\0';
  if (c == EOF) {
    sysbuild_warning("Unexpected end of file");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ignore_whitespace@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x22,%eax
je     116d <read_string+0x3d>
lea    0xea4(%rip),%rdi
call   1050 <sysbuild_warning@plt>
movl   $0x0,-0x4(%rbp)
jmp    1218 <read_string+0xe8>
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x22,-0x1c(%rbp)
mov    %al,-0x21(%rbp)
je     11a1 <read_string+0x71>
mov    -0x1c(%rbp),%eax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b1 <read_string+0x81>
jmp    11db <read_string+0xab>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1180 <read_string+0x50>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
mov    0x2df7(%rip),%rcx
cmp    (%rcx),%eax
jne    1211 <read_string+0xe1>
lea    0xe22(%rip),%rdi
call   1050 <sysbuild_warning@plt>
movl   $0x0,-0x4(%rbp)
jmp    1218 <read_string+0xe8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <ignore_whitespace@plt>
cmp    $0x22,%eax
jne    11a4 <read_string+0x74>
mov    %r12,%rdi
call   1040 <getc@plt>
xor    %ecx,%ecx
mov    0x2e8f(%rip),%r15
cmp    $0x22,%eax
je     118c <read_string+0x5c>
cmp    (%r15),%eax
je     118c <read_string+0x5c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,(%r14,%rbx,1)
mov    %r12,%rdi
call   1040 <getc@plt>
add    $0x1,%rbx
cmp    $0x22,%eax
je     118a <read_string+0x5a>
cmp    (%r15),%eax
jne    1170 <read_string+0x40>
mov    %ebx,%ecx
movb   $0x0,(%r14,%rcx,1)
mov    $0x1,%ecx
cmp    (%r15),%eax
jne    11b2 <read_string+0x82>
lea    0xe80(%rip),%rdi
jmp    11ab <read_string+0x7b>
lea    0xe55(%rip),%rdi
call   1050 <sysbuild_warning@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Failed to find starting quote (\22)\00"
@EOF = global i32 0
@.str.1 = [23 x i8] c"Unexpected end of file\00"
define i32 @read_string(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i32*, i32** %4
%9 = call i32 @ignore_whitespace(i32* %8)
store i32 %9, i32* %6
%10 = icmp ne i32 %9, 34
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @sysbuild_warning(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %48
13: ; preds = %2
%14 = load i32*, i32** %4
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %6
store i32 0, i32* %7
br label %16
16: ; preds = %34, %13
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 34
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %6
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %25, label %37
25: ; preds = %23
%26 = load i32, i32* %6
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
%32 = load i32*, i32** %4
%33 = call i32 @getc(i32* %32)
store i32 %33, i32* %6
br label %34
34: ; preds = %25
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %16
37: ; preds = %23
%38 = load i8*, i8** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i32, i32* %6
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = call i32 @sysbuild_warning(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %48
47: ; preds = %37
store i32 1, i32* %3
br label %48
48: ; preds = %47, %45, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [34 x i8] c"Failed to find starting quote (\22)\00"
@EOF = global i32 0
@.str.1 = [23 x i8] c"Unexpected end of file\00"
define i32 @read_string(i32* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @ignore_whitespace(i32* %0)
%4 = icmp eq i32 %3, 34
br i1 %4, label %5, label %30
5: ; preds = %2
%6 = tail call i32 @getc(i32* %0)
%7 = icmp ne i32 %6, 34
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %24
11: ; preds = %5, %11
%12 = phi i64 [ %17, %11 ], [ 0, %5 ]
%13 = phi i32 [ %16, %11 ], [ %6, %5 ]
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %14, i8* %15
%16 = tail call i32 @getc(i32* %0)
%17 = add nuw i64 %12, 1
%18 = icmp ne i32 %16, 34
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %16, %19
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %11, label %22
22: ; preds = %11
%23 = and i64 %17, 4294967295
br label %24
24: ; preds = %22, %5
%25 = phi i32 [ %6, %5 ], [ %16, %22 ]
%26 = phi i64 [ 0, %5 ], [ %23, %22 ]
%27 = getelementptr inbounds i8, i8* %1, i64 %26
store i8 0, i8* %27
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %25, %28
br i1 %29, label %30, label %33
30: ; preds = %24, %2
%31 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %24 ]
%32 = tail call i32 @sysbuild_warning(i8* %31)
br label %33
33: ; preds = %30, %24
%34 = phi i32 [ 1, %24 ], [ 0, %30 ]
ret i32 %34
}