#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 */
struct tcb {
  int dummy;
};

/* Variables and functions */
char *sprintsigmask_n(char *, char *, long);
int /*<<< orphan*/ tprintf(char *, long);
int /*<<< orphan*/ tprints(char *);
scalar_t__ umoven(struct tcb *, long, long, char *);
void print_sigset_addr_len(struct tcb *tcp, long addr, long len) {
  char mask[32 / 8];
  if (!addr) {
    tprints("NULL");
    return;
  }
  if (len < 0) {
  bad:
    tprintf("%#lx", addr);
    return;
  }
  if (len >= 32 / 8)
    len = 32 / 8;
  else
    len = (len + 3) & ~3;
  if (umoven(tcp, addr, len, mask) < 0)
    goto bad;
  tprints(sprintsigmask_n("", mask, len));
}


x86 assembly (clang, -O0):
<print_sigset_addr_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <print_sigset_addr_len+0x30>
lea    0xe9a(%rip),%rdi
call   1060 <tprints@plt>
jmp    11fd <print_sigset_addr_len+0xbd>
cmpq   $0x0,-0x18(%rbp)
jge    1195 <print_sigset_addr_len+0x55>
jmp    1180 <print_sigset_addr_len+0x40>
mov    -0x10(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1050 <tprintf@plt>
jmp    11fd <print_sigset_addr_len+0xbd>
cmpq   $0x4,-0x18(%rbp)
jl     11ad <print_sigset_addr_len+0x6d>
movq   $0x4,-0x18(%rbp)
jmp    11bd <print_sigset_addr_len+0x7d>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <umoven@plt>
cmp    $0x0,%rax
jge    11e1 <print_sigset_addr_len+0xa1>
jmp    1180 <print_sigset_addr_len+0x40>
lea    -0x1c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe14(%rip),%rdi
call   1040 <sprintsigmask_n@plt>
mov    %rax,%rdi
call   1060 <tprints@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sigset_addr_len>:
test   %rsi,%rsi
je     119a <print_sigset_addr_len+0x5a>
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rdx,%rdx
js     11a6 <print_sigset_addr_len+0x66>
lea    0x3(%rdx),%rax
and    $0xfffffffffffffffc,%rax
cmp    $0x4,%rdx
mov    $0x4,%r14d
cmovb  %rax,%r14
lea    0x4(%rsp),%rcx
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <umoven@plt>
test   %rax,%rax
js     11a6 <print_sigset_addr_len+0x66>
lea    0xe81(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %r14,%rdx
call   1040 <sprintsigmask_n@plt>
mov    %rax,%rdi
call   1060 <tprints@plt>
jmp    11b5 <print_sigset_addr_len+0x75>
lea    0xe5f(%rip),%rdi
jmp    1060 <tprints@plt>
lea    0xe58(%rip),%rdi
mov    %rbx,%rsi
call   1050 <tprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tcb = type { i32 }
@.str = [5 x i8] c"NULL\00"
@.str.1 = [5 x i8] c"%#lx\00"
@.str.2 = [1 x i8] zeroinitializer
define void @print_sigset_addr_len(%struct.tcb* %0, i64 %1, i64 %2) {
%4 = alloca %struct.tcb*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [4 x i8]
store %struct.tcb* %0, %struct.tcb** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %5
%9 = icmp ne i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @tprints(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %40
12: ; preds = %3
%13 = load i64, i64* %6
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
br label %16
16: ; preds = %34, %15
%17 = load i64, i64* %5
%18 = call i32 @tprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %40
19: ; preds = %12
%20 = load i64, i64* %6
%21 = icmp sge i64 %20, 4
br i1 %21, label %22, label %23
22: ; preds = %19
store i64 4, i64* %6
br label %27
23: ; preds = %19
%24 = load i64, i64* %6
%25 = add nsw i64 %24, 3
%26 = and i64 %25, -4
store i64 %26, i64* %6
br label %27
27: ; preds = %23, %22
%28 = load %struct.tcb*, %struct.tcb** %4
%29 = load i64, i64* %5
%30 = load i64, i64* %6
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%32 = call i64 @umoven(%struct.tcb* %28, i64 %29, i64 %30, i8* %31)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %27
br label %16
35: ; preds = %27
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%37 = load i64, i64* %6
%38 = call i8* @sprintsigmask_n(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %36, i64 %37)
%39 = call i32 @tprints(i8* %38)
br label %40
40: ; preds = %35, %16, %10
ret void
}

LLVM IR (-O2):
%struct.tcb = type { i32 }
@.str = [5 x i8] c"NULL\00"
@.str.1 = [5 x i8] c"%#lx\00"
@.str.2 = [1 x i8] zeroinitializer
define void @print_sigset_addr_len(%struct.tcb* %0, i64 %1, i64 %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @tprints(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %23
9: ; preds = %3
%10 = icmp slt i64 %2, 0
br i1 %10, label %11, label %13
11: ; preds = %13, %9
%12 = call i32 @tprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %23
13: ; preds = %9
%14 = add nuw nsw i64 %2, 3
%15 = and i64 %14, -4
%16 = icmp ult i64 %2, 4
%17 = select i1 %16, i64 %15, i64 4
%18 = call i64 @umoven(%struct.tcb* %0, i64 %1, i64 %17, i8* %5)
%19 = icmp slt i64 %18, 0
br i1 %19, label %11, label %20
20: ; preds = %13
%21 = call i8* @sprintsigmask_n(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %5, i64 %17)
%22 = call i32 @tprints(i8* %21)
br label %23
23: ; preds = %20, %11, %7
ret void
}