#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
char *format_signal(int sig) {
  static char buf[10];
  if (!sig)
    snprintf(buf, sizeof(buf), "unknown");
  else
    snprintf(buf, sizeof(buf), "%d dBm", sig);
  return buf;
}


x86 assembly (clang, -O0):
<format_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1144 <format_signal+0x34>
lea    0x2efd(%rip),%rdi
mov    $0xa,%esi
lea    0xec8(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1161 <format_signal+0x51>
mov    -0x4(%rbp),%ecx
lea    0x2edb(%rip),%rdi
mov    $0xa,%esi
lea    0xeae(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2ec1(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_signal>:
push   %rax
test   %edi,%edi
je     1133 <format_signal+0x23>
mov    %edi,%ecx
lea    0x2f0b(%rip),%rdi
lea    0xee3(%rip),%rdx
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    114d <format_signal+0x3d>
lea    0x2eef(%rip),%rdi
lea    0xebf(%rip),%rdx
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2ed5(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@format_signal.buf = internal global [10 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [7 x i8] c"%d dBm\00"
define i8* @format_signal(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %5
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@format_signal.buf = internal global [10 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [7 x i8] c"%d dBm\00"
define i8* @format_signal(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %7
5: ; preds = %1
%6 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %7
7: ; preds = %5, %3
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_signal.buf, i64 0, i64 0)
}