#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 */
scalar_t__ rb_frame_callee();
int /*<<< orphan*/ rb_id2name(scalar_t__);
char *rb_sourcefile();
int rb_sourceline();
int /*<<< orphan*/ warn_printf(char *, char const *, ...);
void error_pos(void) {
  const char *sourcefile = rb_sourcefile();
  int sourceline = rb_sourceline();
  if (sourcefile) {
    if (sourceline == 0) {
      warn_printf("%s", sourcefile);
    } else if (rb_frame_callee()) {
      warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
                  rb_id2name(rb_frame_callee()));
    } else {
      warn_printf("%s:%d", sourcefile, sourceline);
    }
  }
}


x86 assembly (clang, -O0):
<error_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <rb_sourcefile@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rb_sourceline@plt>
mov    %eax,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1202 <error_pos+0xb2>
cmpl   $0x0,-0xc(%rbp)
jne    1199 <error_pos+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <warn_printf@plt>
jmp    11fd <error_pos+0xad>
mov    $0x0,%al
call   1040 <rb_frame_callee@plt>
cmp    $0x0,%rax
je     11e3 <error_pos+0x93>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <rb_frame_callee@plt>
mov    %rax,%rdi
call   1030 <rb_id2name@plt>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <warn_printf@plt>
jmp    11f8 <error_pos+0xa8>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1050 <warn_printf@plt>
jmp    11fd <error_pos+0xad>
jmp    1202 <error_pos+0xb2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_pos>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <rb_sourcefile@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <rb_sourceline@plt>
test   %rbx,%rbx
je     11a5 <error_pos+0x55>
mov    %eax,%ebp
test   %eax,%eax
je     11ac <error_pos+0x5c>
xor    %eax,%eax
call   1040 <rb_frame_callee@plt>
test   %rax,%rax
je     11c3 <error_pos+0x73>
xor    %eax,%eax
call   1040 <rb_frame_callee@plt>
mov    %rax,%rdi
call   1030 <rb_id2name@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <warn_printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <warn_printf@plt>
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <warn_printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"%s:%d:in `%s'\00"
@.str.2 = [6 x i8] c"%s:%d\00"
define void @error_pos() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* (...) @rb_sourcefile()
store i8* %3, i8** %1
%4 = call i32 (...) @rb_sourceline()
store i32 %4, i32* %2
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %28
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i8*, i8** %1
%12 = call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %27
13: ; preds = %7
%14 = call i64 (...) @rb_frame_callee()
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %1
%18 = load i32, i32* %2
%19 = call i64 (...) @rb_frame_callee()
%20 = call i32 @rb_id2name(i64 %19)
%21 = call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18, i32 %20)
br label %26
22: ; preds = %13
%23 = load i8*, i8** %1
%24 = load i32, i32* %2
%25 = call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %24)
br label %26
26: ; preds = %22, %16
br label %27
27: ; preds = %26, %10
br label %28
28: ; preds = %27, %0
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"%s:%d:in `%s'\00"
@.str.2 = [6 x i8] c"%s:%d\00"
define void @error_pos() {
%1 = tail call i8* (...) @rb_sourcefile()
%2 = tail call i32 (...) @rb_sourceline()
%3 = icmp eq i8* %1, null
br i1 %3, label %17, label %4
4: ; preds = %0
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %17
8: ; preds = %4
%9 = tail call i64 (...) @rb_frame_callee()
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i64 (...) @rb_frame_callee()
%13 = tail call i32 @rb_id2name(i64 %12)
%14 = tail call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2, i32 %13)
br label %17
15: ; preds = %8
%16 = tail call i32 (i8*, i8*, ...) @warn_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %2)
br label %17
17: ; preds = %6, %15, %11, %0
ret void
}