#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 /*<<< orphan*/ printf(char *, char *);
int signal_name_to_number(char *);
char *signal_number_to_name(long);
int sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
long strtol(char *, char **, int);
int print_given_signals(int argc, char *argv[], int max_line) {
  char buf[1280];
  int ret = 0;
  int place = 0;
  int amt;
  if (argc > 128)
    return 1;
  while (argc--) {
    char tmpbuf[16];
    char *txt;
    txt = *argv;
    if (*txt >= '0' && *txt <= '9') {
      long val;
      char *endp;
      val = strtol(txt, &endp, 10);
      if (*endp) {
        fprintf(stderr, "Signal \"%s\" not known.\n", txt);
        ret = 1;
        goto end;
      }
      amt = sprintf(tmpbuf, "%s", signal_number_to_name(val));
    } else {
      int sno;
      sno = signal_name_to_number(txt);
      if (sno == -1) {
        fprintf(stderr, "Signal \"%s\" not known.\n", txt);
        ret = 1;
        goto end;
      }
      amt = sprintf(tmpbuf, "%d", sno);
    }
    if (!place) {
      strcpy(buf, tmpbuf);
      place = amt;
      goto end;
    }
    if (amt + place + 1 > max_line) {
      printf("%s\n", buf);
      strcpy(buf, tmpbuf);
      place = amt;
      goto end;
    }
    sprintf(buf + place, " %s", tmpbuf);
    place += amt + 1;
  end:
    argv++;
  }
  if (place)
    printf("%s\n", buf);
  return ret;
}


x86 assembly (clang, -O0):
<print_given_signals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x570,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x524(%rbp)
movl   $0x0,-0x528(%rbp)
cmpl   $0x80,-0x8(%rbp)
jle    11b2 <print_given_signals+0x42>
movl   $0x1,-0x4(%rbp)
jmp    13f6 <print_given_signals+0x286>
jmp    11b7 <print_given_signals+0x47>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     13cd <print_given_signals+0x25d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x548(%rbp)
mov    -0x548(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1296 <print_given_signals+0x126>
mov    -0x548(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     1296 <print_given_signals+0x126>
mov    -0x548(%rbp),%rdi
lea    -0x558(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x550(%rbp)
mov    -0x558(%rbp),%rax
cmpb   $0x0,(%rax)
je     1259 <print_given_signals+0xe9>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
mov    -0x548(%rbp),%rdx
lea    0xdbb(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x524(%rbp)
jmp    13bc <print_given_signals+0x24c>
lea    -0x540(%rbp),%rax
mov    %rax,-0x568(%rbp)
mov    -0x550(%rbp),%rdi
call   1080 <signal_number_to_name@plt>
mov    -0x568(%rbp),%rdi
mov    %rax,%rdx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    %eax,-0x52c(%rbp)
jmp    1301 <print_given_signals+0x191>
mov    -0x548(%rbp),%rdi
call   1040 <signal_name_to_number@plt>
mov    %eax,-0x55c(%rbp)
cmpl   $0xffffffff,-0x55c(%rbp)
jne    12e0 <print_given_signals+0x170>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    -0x548(%rbp),%rdx
lea    0xd34(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x524(%rbp)
jmp    13bc <print_given_signals+0x24c>
lea    -0x540(%rbp),%rdi
mov    -0x55c(%rbp),%edx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    %eax,-0x52c(%rbp)
cmpl   $0x0,-0x528(%rbp)
jne    1332 <print_given_signals+0x1c2>
lea    -0x520(%rbp),%rdi
lea    -0x540(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x52c(%rbp),%eax
mov    %eax,-0x528(%rbp)
jmp    13bc <print_given_signals+0x24c>
mov    -0x52c(%rbp),%eax
add    -0x528(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jle    1381 <print_given_signals+0x211>
lea    -0x520(%rbp),%rsi
lea    0xcc3(%rip),%rdi
call   1050 <printf@plt>
lea    -0x520(%rbp),%rdi
lea    -0x540(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x52c(%rbp),%eax
mov    %eax,-0x528(%rbp)
jmp    13bc <print_given_signals+0x24c>
lea    -0x520(%rbp),%rdi
movslq -0x528(%rbp),%rax
add    %rax,%rdi
lea    -0x540(%rbp),%rdx
lea    0xc7f(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x52c(%rbp),%eax
add    $0x1,%eax
add    -0x528(%rbp),%eax
mov    %eax,-0x528(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11b7 <print_given_signals+0x47>
cmpl   $0x0,-0x528(%rbp)
je     13ed <print_given_signals+0x27d>
lea    -0x520(%rbp),%rsi
lea    0xc33(%rip),%rdi
call   1050 <printf@plt>
mov    -0x524(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x570,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_given_signals>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x538,%rsp
mov    %edx,0xc(%rsp)
mov    $0x1,%eax
cmp    $0x80,%edi
jg     12f3 <print_given_signals+0x173>
test   %edi,%edi
je     12f1 <print_given_signals+0x171>
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %r12d,%r12d
xor    %r14d,%r14d
movl   $0x0,0x8(%rsp)
jmp    121a <print_given_signals+0x9a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x28(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    0x28(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1282 <print_given_signals+0x102>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
mov    %rbp,%rdx
call   1070 <fprintf@plt>
movl   $0x1,0x8(%rsp)
add    $0x1,%r12
cmp    %r12d,%r15d
je     12d5 <print_given_signals+0x155>
mov    (%rbx,%r12,8),%rbp
movzbl 0x0(%rbp),%eax
add    $0xd0,%al
mov    %rbp,%rdi
cmp    $0x9,%al
jbe    11d0 <print_given_signals+0x50>
call   1050 <signal_name_to_number@plt>
cmp    $0xffffffff,%eax
je     11ed <print_given_signals+0x6d>
lea    0x10(%rsp),%rdi
lea    0xdd7(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %eax,%r13d
test   %r14d,%r14d
je     12a5 <print_given_signals+0x125>
lea    (%r14,%r13,1),%ebp
cmp    0xc(%rsp),%ebp
jge    12ac <print_given_signals+0x12c>
movslq %r14d,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
lea    0xdb1(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
add    $0x1,%ebp
mov    %ebp,%r14d
jmp    120d <print_given_signals+0x8d>
mov    %rax,%rdi
call   1090 <signal_number_to_name@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1040 <stpcpy@plt>
mov    %rax,%r13
sub    %ebp,%r13d
test   %r14d,%r14d
jne    1252 <print_given_signals+0xd2>
lea    0x30(%rsp),%rdi
jmp    12c3 <print_given_signals+0x143>
lea    0xd68(%rip),%rdi
lea    0x30(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <printf@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
call   1030 <strcpy@plt>
mov    %r13d,%r14d
jmp    120d <print_given_signals+0x8d>
test   %r14d,%r14d
je     12eb <print_given_signals+0x16b>
lea    0xd3a(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1060 <printf@plt>
mov    0x8(%rsp),%eax
jmp    12f3 <print_given_signals+0x173>
xor    %eax,%eax
add    $0x538,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Signal \22%s\22 not known.\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c" %s\00"
define i32 @print_given_signals(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [1280 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [16 x i8]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 128
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 1, i32* %4
br label %109
20: ; preds = %3
br label %21
21: ; preds = %98, %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, -1
store i32 %23, i32* %5
%24 = icmp ne i32 %22, 0
br i1 %24, label %25, label %101
25: ; preds = %21
%26 = load i8**, i8*** %6
%27 = load i8*, i8** %26
store i8* %27, i8** %13
%28 = load i8*, i8** %13
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp sge i32 %30, 48
br i1 %31, label %32, label %52
32: ; preds = %25
%33 = load i8*, i8** %13
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 57
br i1 %36, label %37, label %52
37: ; preds = %32
%38 = load i8*, i8** %13
%39 = call i64 @strtol(i8* %38, i8** %15, i32 10)
store i64 %39, i64* %14
%40 = load i8*, i8** %15
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %13
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %45)
store i32 1, i32* %9
br label %98
47: ; preds = %37
%48 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%49 = load i64, i64* %14
%50 = call i8* @signal_number_to_name(i64 %49)
%51 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %50)
store i32 %51, i32* %11
br label %65
52: ; preds = %32, %25
%53 = load i8*, i8** %13
%54 = call i32 @signal_name_to_number(i8* %53)
store i32 %54, i32* %16
%55 = load i32, i32* %16
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %61
57: ; preds = %52
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %13
%60 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %59)
store i32 1, i32* %9
br label %98
61: ; preds = %52
%62 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%63 = load i32, i32* %16
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63)
store i32 %64, i32* %11
br label %65
65: ; preds = %61, %47
%66 = load i32, i32* %10
%67 = icmp ne i32 %66, 0
br i1 %67, label %73, label %68
68: ; preds = %65
%69 = getelementptr inbounds [1280 x i8], [1280 x i8]* %8, i64 0, i64 0
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%71 = call i32 @strcpy(i8* %69, i8* %70)
%72 = load i32, i32* %11
store i32 %72, i32* %10
br label %98
73: ; preds = %65
%74 = load i32, i32* %11
%75 = load i32, i32* %10
%76 = add nsw i32 %74, %75
%77 = add nsw i32 %76, 1
%78 = load i32, i32* %7
%79 = icmp sgt i32 %77, %78
br i1 %79, label %80, label %87
80: ; preds = %73
%81 = getelementptr inbounds [1280 x i8], [1280 x i8]* %8, i64 0, i64 0
%82 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %81)
%83 = getelementptr inbounds [1280 x i8], [1280 x i8]* %8, i64 0, i64 0
%84 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%85 = call i32 @strcpy(i8* %83, i8* %84)
%86 = load i32, i32* %11
store i32 %86, i32* %10
br label %98
87: ; preds = %73
%88 = getelementptr inbounds [1280 x i8], [1280 x i8]* %8, i64 0, i64 0
%89 = load i32, i32* %10
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%93 = call i32 (i8*, i8*, ...) @sprintf(i8* %91, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %92)
%94 = load i32, i32* %11
%95 = add nsw i32 %94, 1
%96 = load i32, i32* %10
%97 = add nsw i32 %96, %95
store i32 %97, i32* %10
br label %98
98: ; preds = %87, %80, %68, %57, %43
%99 = load i8**, i8*** %6
%100 = getelementptr inbounds i8*, i8** %99, i32 1
store i8** %100, i8*** %6
br label %21
101: ; preds = %21
%102 = load i32, i32* %10
%103 = icmp ne i32 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = getelementptr inbounds [1280 x i8], [1280 x i8]* %8, i64 0, i64 0
%106 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %105)
br label %107
107: ; preds = %104, %101
%108 = load i32, i32* %9
store i32 %108, i32* %4
br label %109
109: ; preds = %107, %19
%110 = load i32, i32* %4
ret i32 %110
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Signal \22%s\22 not known.\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c" %s\00"
define i32 @print_given_signals(i32 %0, i8** nocapture %1, i32 %2) {
%4 = alloca [1280 x i8]
%5 = alloca [16 x i8]
%6 = alloca i8*
%7 = getelementptr inbounds [1280 x i8], [1280 x i8]* %4, i64 0, i64 0
%8 = icmp sgt i32 %0, 128
br i1 %8, label %72, label %9
9: ; preds = %3
%10 = icmp eq i32 %0, 0
br i1 %10, label %72, label %11
11: ; preds = %9
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%13 = bitcast i8** %6 to i8*
%14 = ptrtoint [16 x i8]* %5 to i64
br label %15
15: ; preds = %11, %63
%16 = phi i32 [ %0, %11 ], [ %20, %63 ]
%17 = phi i8** [ %1, %11 ], [ %66, %63 ]
%18 = phi i32 [ 0, %11 ], [ %65, %63 ]
%19 = phi i32 [ 0, %11 ], [ %64, %63 ]
%20 = add nsw i32 %16, -1
%21 = load i8*, i8** %17
%22 = load i8, i8* %21
%23 = add i8 %22, -48
%24 = icmp ult i8 %23, 10
br i1 %24, label %25, label %39
25: ; preds = %15
%26 = call i64 @strtol(i8* %21, i8** %6, i32 10)
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = call i8* @signal_number_to_name(i64 %26)
%32 = call i8* @stpcpy(i8* %12, i8* %31)
%33 = ptrtoint i8* %32 to i64
%34 = sub i64 %33, %14
%35 = trunc i64 %34 to i32
br label %47
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %63
39: ; preds = %15
%40 = call i32 @signal_name_to_number(i8* %21)
%41 = icmp eq i32 %40, -1
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
br label %47
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %63
47: ; preds = %42, %30
%48 = phi i32 [ %35, %30 ], [ %43, %42 ]
%49 = icmp eq i32 %18, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @strcpy(i8* %7, i8* %12)
br label %63
52: ; preds = %47
%53 = add i32 %48, %18
%54 = icmp slt i32 %53, %2
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%57 = call i32 @strcpy(i8* %7, i8* %12)
br label %63
58: ; preds = %52
%59 = sext i32 %18 to i64
%60 = getelementptr inbounds [1280 x i8], [1280 x i8]* %4, i64 0, i64 %59
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%62 = add nsw i32 %53, 1
br label %63
63: ; preds = %44, %36, %58, %55, %50
%64 = phi i32 [ 1, %36 ], [ %19, %55 ], [ %19, %58 ], [ %19, %50 ], [ 1, %44 ]
%65 = phi i32 [ %18, %36 ], [ %48, %55 ], [ %62, %58 ], [ %48, %50 ], [ %18, %44 ]
%66 = getelementptr inbounds i8*, i8** %17, i64 1
%67 = icmp eq i32 %20, 0
br i1 %67, label %68, label %15
68: ; preds = %63
%69 = icmp eq i32 %65, 0
br i1 %69, label %72, label %70
70: ; preds = %68
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %72
72: ; preds = %9, %68, %70, %3
%73 = phi i32 [ 1, %3 ], [ %64, %70 ], [ %64, %68 ], [ 0, %9 ]
ret i32 %73
}