#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 */
long error_pop();
int /*<<< orphan*/ error_str(long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, long,
                           int /*<<< orphan*/);
void error_print(FILE *fp, const char *func) {
  long code;
  while ((code = error_pop()) != 0) {
    fprintf(fp, "error:%s:%04lu:%s\n", func, code, error_str(code));
  }
}


x86 assembly (clang, -O0):
<error_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <error_pop@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1196 <error_print+0x66>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <error_str@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %eax,%r8d
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1140 <error_print+0x10>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
xor    %eax,%eax
call   1050 <error_pop@plt>
test   %rax,%rax
je     118b <error_print+0x5b>
mov    %rax,%rbx
lea    0xeac(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <error_str@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <error_pop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1160 <error_print+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"error:%s:%04lu:%s\0A\00"
define void @error_print(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %9, %2
%7 = call i64 (...) @error_pop()
store i64 %7, i64* %5
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i8*, i8** %4
%12 = load i64, i64* %5
%13 = load i64, i64* %5
%14 = call i32 @error_str(i64 %13)
%15 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11, i64 %12, i32 %14)
br label %6
16: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"error:%s:%04lu:%s\0A\00"
define void @error_print(i32* nocapture %0, i8* %1) {
%3 = tail call i64 (...) @error_pop()
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %9, %5 ], [ %3, %2 ]
%7 = tail call i32 @error_str(i64 %6)
%8 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %1, i64 %6, i32 %7)
%9 = tail call i64 (...) @error_pop()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %5
11: ; preds = %5, %2
ret void
}