#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*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ stderr;
char *at_ref(char *buf, int seq, int control) {
  if (buf != NULL)
    sprintf(buf, "AT*REF=%d,%d\r", seq, control);
  else
    fprintf(stderr, "[%s:%d] Error: Buffer is null!",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/super7ramp/Leonard/refs/heads/master/"
            "src/com/at-commands.c",
            26);
  return buf;
}


x86 assembly (clang, -O0):
<at_ref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1158 <at_ref+0x38>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeb2(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1179 <at_ref+0x59>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
lea    0xebe(%rip),%rdx
mov    $0x1a,%ecx
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at_ref>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     113e <at_ref+0x1e>
mov    %edx,%ecx
mov    %esi,%edx
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
jmp    115f <at_ref+0x3f>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xec0(%rip),%rsi
lea    0xed8(%rip),%rdx
mov    $0x1a,%ecx
call   1030 <fprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"AT*REF=%d,%d\0D\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"[%s:%d] Error: Buffer is null!\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/super7ramp/Leonard/refs/heads/master/src/com/at-commands.c\00"
define i8* @at_ref(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
br label %17
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 26)
br label %17
17: ; preds = %14, %9
%18 = load i8*, i8** %4
ret i8* %18
}

LLVM IR (-O2):
@.str = [14 x i8] c"AT*REF=%d,%d\0D\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"[%s:%d] Error: Buffer is null!\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/super7ramp/Leonard/refs/heads/master/src/com/at-commands.c\00"
define i8* @at_ref(i8* returned writeonly %0, i32 %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @sprintf(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
br label %10
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 26)
br label %10
10: ; preds = %7, %5
ret i8* %0
}