#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 */
char EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
void string(FILE *fp, FILE *tp) {
  putc('"', tp);
  char a = getc(fp);
  while (a != '"') {
    if (a == EOF) {
      printf("Error\n");
      exit(0);
    }
    putc(a, tp);
    a = getc(fp);
  }
  putc('"', tp);
}


x86 assembly (clang, -O0):
<string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x22,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x22,%eax
je     11c0 <string+0x80>
movsbl -0x11(%rbp),%eax
mov    0x2e66(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11a0 <string+0x60>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x11(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x11(%rbp)
jmp    116a <string+0x2a>
mov    -0x10(%rbp),%rsi
mov    $0x22,%edi
call   1040 <putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x22,%edi
call   1040 <putc@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    $0x22,%al
je     118c <string+0x4c>
mov    0x2e80(%rip),%r15
nopl   0x0(%rax,%rax,1)
cmp    (%r15),%al
je     119e <string+0x5e>
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    $0x22,%al
jne    1170 <string+0x30>
mov    $0x22,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <putc@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [7 x i8] c"Error\0A\00"
define void @string(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @putc(i8 signext 34, i32* %6)
%8 = load i32*, i32** %3
%9 = call signext i8 @getc(i32* %8)
store i8 %9, i8* %5
br label %10
10: ; preds = %23, %2
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 34
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %14
%24 = load i8, i8* %5
%25 = load i32*, i32** %4
%26 = call i32 @putc(i8 signext %24, i32* %25)
%27 = load i32*, i32** %3
%28 = call signext i8 @getc(i32* %27)
store i8 %28, i8* %5
br label %10
29: ; preds = %10
%30 = load i32*, i32** %4
%31 = call i32 @putc(i8 signext 34, i32* %30)
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@str = [6 x i8] c"Error\00"
define void @string(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @putc(i8 signext 34, i32* %1)
%4 = tail call signext i8 @getc(i32* %0)
%5 = icmp eq i8 %4, 34
br i1 %5, label %17, label %6
6: ; preds = %2, %13
%7 = phi i8 [ %15, %13 ], [ %4, %2 ]
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %6
%14 = tail call i32 @putc(i8 signext %7, i32* %1)
%15 = tail call signext i8 @getc(i32* %0)
%16 = icmp eq i8 %15, 34
br i1 %16, label %17, label %6
17: ; preds = %13, %2
%18 = tail call i32 @putc(i8 signext 34, i32* %1)
ret void
}