#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 _NSIG;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sig2str(int, char *);
int /*<<< orphan*/ str2sig(char *, int *);
void test_conv() {
  printf("-----str2sig-----\n");
  int signo;
  char str[10] = {0};
  for (int i = 0; i < _NSIG; ++i) {
    sig2str(i, str);
    str2sig(str, &signo);
    printf("[%d][%d] %s\n", i, signo, str);
  }
}


x86 assembly (clang, -O0):
<test_conv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
jge    11be <test_conv+0x7e>
mov    -0x14(%rbp),%edi
lea    -0xe(%rbp),%rsi
call   1060 <sig2str@plt>
lea    -0xe(%rbp),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <str2sig@plt>
mov    -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    -0xe(%rbp),%rcx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <test_conv+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_conv>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e81(%rip),%r12
cmpl   $0x0,(%r12)
jle    11c1 <test_conv+0x81>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r14
lea    0xe79(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <sig2str@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <str2sig@plt>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    (%r12),%ebp
jl     1190 <test_conv+0x50>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"-----str2sig-----\0A\00"
@_NSIG = global i32 0
@.str.1 = [13 x i8] c"[%d][%d] %s\0A\00"
define void @test_conv() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [10 x i8]* %2 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %3
%8 = load i32, i32* @_NSIG
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load i32, i32* %3
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i32 @sig2str(i32 %11, i8* %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%15 = call i32 @str2sig(i8* %14, i32* %1)
%16 = load i32, i32* %3
%17 = load i32, i32* %1
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17, i8* %18)
br label %20
20: ; preds = %10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
ret void
}

LLVM IR (-O2):
@_NSIG = global i32 0
@.str.1 = [13 x i8] c"[%d][%d] %s\0A\00"
@str = [18 x i8] c"-----str2sig-----\00"
define void @test_conv() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @_NSIG
%7 = icmp sgt i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %9, %0
ret void
9: ; preds = %0, %9
%10 = phi i32 [ %15, %9 ], [ 0, %0 ]
%11 = call i32 @sig2str(i32 %10, i8* %5)
%12 = call i32 @str2sig(i8* %5, i32* %1)
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %13, i8* %5)
%15 = add nuw nsw i32 %10, 1
%16 = load i32, i32* @_NSIG
%17 = icmp slt i32 %15, %16
br i1 %17, label %9, label %8
}