#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 ss7 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ isup_get_number(char *, unsigned char *, int, int);
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, ...);
int((redirecting_number_dump))(struct ss7 *ss7, int messagetype,
                               unsigned char *parm, int len) {
  int oddeven = (parm[0] >> 7) & 0x1;
  char numbuf[64] = "";
  ss7_message(ss7, "\t\t\tNature of address: %x\n", parm[0] & 0x7f);
  ss7_message(ss7, "\t\t\tNI: %x\n", (parm[1] >> 7) & 0x1);
  ss7_message(ss7, "\t\t\tNumbering plan: %x\n", (parm[1] >> 4) & 0x7);
  ss7_message(ss7, "\t\t\tPresentation: %x\n", (parm[1] >> 2) & 0x3);
  ss7_message(ss7, "\t\t\tScreening: %x\n", parm[1] & 0x3);
  isup_get_number(numbuf, &parm[2], len - 2, oddeven);
  ss7_message(ss7, "\t\t\tAddress signals: %s\n", numbuf);
  return len;
}


x86 assembly (clang, -O0):
<redirecting_number_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
sar    $0x7,%eax
and    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
and    $0x7f,%edx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x7,%edx
and    $0x1,%edx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x4,%edx
and    $0x7,%edx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x2,%edx
and    $0x3,%edx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
and    $0x3,%edx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x2,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x2,%edx
mov    -0x20(%rbp),%ecx
call   1040 <isup_get_number@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redirecting_number_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rdi,%r15
movzbl (%rdx),%edx
mov    %edx,%r12d
shr    $0x7,%r12d
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
and    $0x7f,%edx
lea    0xea1(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x7,%edx
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xe96(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x2,%edx
and    $0x3,%edx
lea    0xe92(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
and    $0x3,%edx
lea    0xe8f(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x2,%rbx
lea    -0x2(%r14),%edx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%ecx
call   1030 <isup_get_number@plt>
lea    0xe77(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <ss7_message@plt>
mov    %r14d,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [11 x i8] c"\09\09\09NI: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.3 = [21 x i8] c"\09\09\09Presentation: %x\0A\00"
@.str.4 = [18 x i8] c"\09\09\09Screening: %x\0A\00"
@.str.5 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @redirecting_number_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.ss7*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [64 x i8]
store %struct.ss7* %0, %struct.ss7** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %7
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 7
%16 = and i32 %15, 1
store i32 %16, i32* %9
%17 = bitcast [64 x i8]* %10 to i8*
%18 = load %struct.ss7*, %struct.ss7** %5
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = and i32 %22, 127
%24 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load %struct.ss7*, %struct.ss7** %5
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = ashr i32 %29, 7
%31 = and i32 %30, 1
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load %struct.ss7*, %struct.ss7** %5
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = ashr i32 %37, 4
%39 = and i32 %38, 7
%40 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load %struct.ss7*, %struct.ss7** %5
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = ashr i32 %45, 2
%47 = and i32 %46, 3
%48 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = load %struct.ss7*, %struct.ss7** %5
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 3
%55 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %49, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%57 = load i8*, i8** %7
%58 = getelementptr inbounds i8, i8* %57, i64 2
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 2
%61 = load i32, i32* %9
%62 = call i32 @isup_get_number(i8* %56, i8* %58, i32 %60, i32 %61)
%63 = load %struct.ss7*, %struct.ss7** %5
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%65 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %63, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %64)
%66 = load i32, i32* %8
ret i32 %66
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [11 x i8] c"\09\09\09NI: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.3 = [21 x i8] c"\09\09\09Presentation: %x\0A\00"
@.str.4 = [18 x i8] c"\09\09\09Screening: %x\0A\00"
@.str.5 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @redirecting_number_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 returned %3) {
%5 = alloca [64 x i8]
%6 = load i8, i8* %2
%7 = lshr i8 %6, 7
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = and i8 %6, 127
%11 = zext i8 %10 to i32
%12 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %2, i64 1
%14 = load i8, i8* %13
%15 = lshr i8 %14, 7
%16 = zext i8 %15 to i32
%17 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i8, i8* %13
%19 = lshr i8 %18, 4
%20 = and i8 %19, 7
%21 = zext i8 %20 to i32
%22 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i8, i8* %13
%24 = lshr i8 %23, 2
%25 = and i8 %24, 3
%26 = zext i8 %25 to i32
%27 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i8, i8* %13
%29 = and i8 %28, 3
%30 = zext i8 %29 to i32
%31 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds i8, i8* %2, i64 2
%33 = add nsw i32 %3, -2
%34 = call i32 @isup_get_number(i8* %9, i8* %32, i32 %33, i32 %8)
%35 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %9)
ret i32 %3
}