#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 *, ...);
char **sys_siglist;
void test_siglist() {
  printf("-----sys_siglist-----\n");
  for (int i = 0; i < _NSIG; ++i)
    printf("%s: %d\n", sys_siglist[i], i);
  printf("\n");
}


x86 assembly (clang, -O0):
<test_siglist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb9(%rip),%rcx
cmp    (%rcx),%eax
jge    1170 <test_siglist+0x60>
mov    0x2e9a(%rip),%rax
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x4(%rbp),%edx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <test_siglist+0x1d>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_siglist>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ea5(%rip),%r15
cmpl   $0x0,(%r15)
jle    1190 <test_siglist+0x60>
mov    0x2e88(%rip),%r12
lea    0xea1(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1170 <test_siglist+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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