#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*/ abort();
int /*<<< orphan*/ foo(char const **, char *, int, int);
scalar_t__ strcmp(char const *, char *);
int main(void) {
  char buf[64];
  const char *p;
  p = "abcde'fgh";
  foo(&p, buf, 1, 0);
  if (strcmp(p, "fgh") != 0 || strcmp(buf, "abcde") != 0)
    abort();
  p = "ABCDEFG\"HI";
  foo(&p, buf, 0, 1);
  if (strcmp(p, "HI") != 0 || strcmp(buf, "ABCDEFG") != 0)
    abort();
  p = "abcd\"e'fgh";
  foo(&p, buf, 1, 1);
  if (strcmp(p, "e'fgh") != 0 || strcmp(buf, "abcd") != 0)
    abort();
  p = "ABCDEF'G\"HI";
  foo(&p, buf, 1, 1);
  if (strcmp(p, "G\"HI") != 0 || strcmp(buf, "ABCDEF") != 0)
    abort();
  p = "abcdef@gh";
  foo(&p, buf, 0, 0);
  if (strcmp(p, "gh") != 0 || strcmp(buf, "abcdef") != 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1050 <foo@plt>
mov    -0x58(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1192 <main+0x62>
lea    -0x50(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1199 <main+0x69>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe70(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <foo@plt>
mov    -0x58(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <main+0xbc>
lea    -0x50(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11f3 <main+0xc3>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe29(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <foo@plt>
mov    -0x58(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1246 <main+0x116>
lea    -0x50(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     124d <main+0x11d>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xddf(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <foo@plt>
mov    -0x58(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a0 <main+0x170>
lea    -0x50(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12a7 <main+0x177>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xd98(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1050 <foo@plt>
mov    -0x58(%rbp),%rdi
lea    0xd7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12f7 <main+0x1c7>
lea    -0x50(%rbp),%rdi
lea    0xd68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12fe <main+0x1ce>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0xec5(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1050 <foo@plt>
mov    0x8(%rsp),%rdi
lea    0xec8(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xe93(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xe7f(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <foo@plt>
mov    0x8(%rsp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xe4e(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xe3c(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <foo@plt>
mov    0x8(%rsp),%rdi
lea    0xe17(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xe08(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xdf3(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <foo@plt>
mov    0x8(%rsp),%rdi
lea    0xdd0(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xdc4(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xdb5(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <foo@plt>
mov    0x8(%rsp),%rdi
lea    0xd98(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
lea    0xd8a(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12dc <main+0x1ac>
xor    %eax,%eax
add    $0x58,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"abcde'fgh\00"
@.str.1 = [4 x i8] c"fgh\00"
@.str.2 = [6 x i8] c"abcde\00"
@.str.3 = [11 x i8] c"ABCDEFG\22HI\00"
@.str.4 = [3 x i8] c"HI\00"
@.str.5 = [8 x i8] c"ABCDEFG\00"
@.str.6 = [11 x i8] c"abcd\22e'fgh\00"
@.str.7 = [6 x i8] c"e'fgh\00"
@.str.8 = [5 x i8] c"abcd\00"
@.str.9 = [12 x i8] c"ABCDEF'G\22HI\00"
@.str.10 = [5 x i8] c"G\22HI\00"
@.str.11 = [7 x i8] c"ABCDEF\00"
@.str.12 = [10 x i8] c"abcdef@gh\00"
@.str.13 = [3 x i8] c"gh\00"
@.str.14 = [7 x i8] c"abcdef\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = call i32 @foo(i8** %3, i8* %4, i32 1, i32 0)
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9, %0
%14 = call i32 (...) @abort()
unreachable
15: ; preds = %9
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %3
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%17 = call i32 @foo(i8** %3, i8* %16, i32 0, i32 1)
%18 = load i8*, i8** %3
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21, %15
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %21
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %3
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%29 = call i32 @foo(i8** %3, i8* %28, i32 1, i32 1)
%30 = load i8*, i8** %3
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33, %27
%38 = call i32 (...) @abort()
unreachable
39: ; preds = %33
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8** %3
%40 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%41 = call i32 @foo(i8** %3, i8* %40, i32 1, i32 1)
%42 = load i8*, i8** %3
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%44 = icmp ne i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %39
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45, %39
%50 = call i32 (...) @abort()
unreachable
51: ; preds = %45
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %3
%52 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%53 = call i32 @foo(i8** %3, i8* %52, i32 0, i32 0)
%54 = load i8*, i8** %3
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%56 = icmp ne i64 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %51
%58 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %57, %51
%62 = call i32 (...) @abort()
unreachable
63: ; preds = %57
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"abcde'fgh\00"
@.str.1 = [4 x i8] c"fgh\00"
@.str.2 = [6 x i8] c"abcde\00"
@.str.3 = [11 x i8] c"ABCDEFG\22HI\00"
@.str.4 = [3 x i8] c"HI\00"
@.str.5 = [8 x i8] c"ABCDEFG\00"
@.str.6 = [11 x i8] c"abcd\22e'fgh\00"
@.str.7 = [6 x i8] c"e'fgh\00"
@.str.8 = [5 x i8] c"abcd\00"
@.str.9 = [12 x i8] c"ABCDEF'G\22HI\00"
@.str.10 = [5 x i8] c"G\22HI\00"
@.str.11 = [7 x i8] c"ABCDEF\00"
@.str.12 = [10 x i8] c"abcdef@gh\00"
@.str.13 = [3 x i8] c"gh\00"
@.str.14 = [7 x i8] c"abcdef\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = bitcast i8** %2 to i8*
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = call i32 @foo(i8** %2, i8* %3, i32 1, i32 0)
%6 = load i8*, i8** %2
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9, %0
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %9
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %2
%15 = call i32 @foo(i8** %2, i8* %3, i32 0, i32 1)
%16 = load i8*, i8** %2
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19, %14
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %19
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %2
%25 = call i32 @foo(i8** %2, i8* %3, i32 1, i32 1)
%26 = load i8*, i8** %2
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29, %24
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %29
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8** %2
%35 = call i32 @foo(i8** %2, i8* %3, i32 1, i32 1)
%36 = load i8*, i8** %2
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39, %34
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %39
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %2
%45 = call i32 @foo(i8** %2, i8* %3, i32 0, i32 0)
%46 = load i8*, i8** %2
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %49, %44
%53 = call i32 (...) @abort()
unreachable
54: ; preds = %49
ret i32 0
}