#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 buf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bputs(struct buf *, char *);
struct buf *mkbuf();
char *strchrnul(char *, char);
struct buf *compilestr(char *in, char **out) {
  struct buf *b = mkbuf();
  char *e = strchrnul(in, '"');
  *out = *e ? e + 1 : NULL;
  *e = '\0';
  bputs(b, "\t.asciz \"");
  bputs(b, in);
  bputs(b, "\"\n");
  return b;
}


x86 assembly (clang, -O0):
<compilestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <mkbuf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strchrnul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117e <compilestr+0x4e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <compilestr+0x59>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1189 <compilestr+0x59>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <bputs@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <bputs@plt>
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <bputs@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compilestr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <mkbuf@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    $0x22,%esi
call   1040 <strchrnul@plt>
lea    0x1(%rax),%rcx
cmpb   $0x0,(%rax)
cmovne %rcx,%rbx
mov    %rbx,(%r14)
movb   $0x0,(%rax)
lea    0xe91(%rip),%rsi
mov    %r12,%rdi
call   1030 <bputs@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <bputs@plt>
lea    0xe81(%rip),%rsi
mov    %r12,%rdi
call   1030 <bputs@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.buf = type { i32 }
@.str = [10 x i8] c"\09.asciz \22\00"
@.str.1 = [3 x i8] c"\22\0A\00"
define %struct.buf* @compilestr(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca %struct.buf*
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = call %struct.buf* (...) @mkbuf()
store %struct.buf* %7, %struct.buf** %5
%8 = load i8*, i8** %3
%9 = call i8* @strchrnul(i8* %8, i8 signext 34)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 1
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %14
%19 = phi i8* [ %16, %14 ], [ null, %17 ]
%20 = load i8**, i8*** %4
store i8* %19, i8** %20
%21 = load i8*, i8** %6
store i8 0, i8* %21
%22 = load %struct.buf*, %struct.buf** %5
%23 = call i32 @bputs(%struct.buf* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%24 = load %struct.buf*, %struct.buf** %5
%25 = load i8*, i8** %3
%26 = call i32 @bputs(%struct.buf* %24, i8* %25)
%27 = load %struct.buf*, %struct.buf** %5
%28 = call i32 @bputs(%struct.buf* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = load %struct.buf*, %struct.buf** %5
ret %struct.buf* %29
}

LLVM IR (-O2):
%struct.buf = type { i32 }
@.str = [10 x i8] c"\09.asciz \22\00"
@.str.1 = [3 x i8] c"\22\0A\00"
define %struct.buf* @compilestr(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call %struct.buf* (...) @mkbuf()
%4 = tail call i8* @strchrnul(i8* %0, i8 signext 34)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = select i1 %6, i8* null, i8* %7
store i8* %8, i8** %1
store i8 0, i8* %4
%9 = tail call i32 @bputs(%struct.buf* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @bputs(%struct.buf* %3, i8* %0)
%11 = tail call i32 @bputs(%struct.buf* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret %struct.buf* %3
}