#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((generic_address_dump))(struct ss7 *ss7, int messagetype,
                            unsigned char *parm, int len) {
  int oddeven = (parm[1] >> 7) & 0x1;
  char numbuf[64] = "";
  ss7_message(ss7, "\t\t\tType of address: %x\n", parm[0]);
  ss7_message(ss7, "\t\t\tNature of address: %x\n", parm[1] & 0x7f);
  ss7_message(ss7, "\t\t\tOddEven: %x\n", (parm[1] >> 7) & 0x1);
  ss7_message(ss7, "\t\t\tReserved: %x\n", parm[2] & 0x3);
  ss7_message(ss7, "\t\t\tPresentation: %x\n", (parm[2] >> 2) & 0x3);
  ss7_message(ss7, "\t\t\tNumbering plan: %x\n", (parm[2] >> 4) & 0x7);
  isup_get_number(numbuf, &parm[3], len - 3, oddeven);
  ss7_message(ss7, "\t\t\tAddress signals: %s\n", numbuf);
  return len;
}


x86 assembly (clang, -O0):
<generic_address_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 0x1(%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
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
and    $0x7f,%edx
lea    0xe82(%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    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0x3,%edx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%edx
sar    $0x2,%edx
and    $0x3,%edx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%edx
sar    $0x4,%edx
and    $0x7,%edx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x3,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x3,%edx
mov    -0x20(%rbp),%ecx
call   1040 <isup_get_number@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generic_address_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rdi,%rbx
movzbl 0x1(%rdx),%r15d
shr    $0x7,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movzbl (%rdx),%edx
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbp),%edx
and    $0x7f,%edx
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbp),%edx
shr    $0x7,%edx
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x2(%rbp),%edx
and    $0x3,%edx
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x2(%rbp),%edx
shr    $0x2,%edx
and    $0x3,%edx
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x2(%rbp),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x3,%rbp
lea    -0x3(%r14),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15d,%ecx
call   1030 <isup_get_number@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%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 = [24 x i8] c"\09\09\09Type of address: %x\0A\00"
@.str.1 = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.2 = [16 x i8] c"\09\09\09OddEven: %x\0A\00"
@.str.3 = [17 x i8] c"\09\09\09Reserved: %x\0A\00"
@.str.4 = [21 x i8] c"\09\09\09Presentation: %x\0A\00"
@.str.5 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.6 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @generic_address_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 1
%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 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load %struct.ss7*, %struct.ss7** %5
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = and i32 %28, 127
%30 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load %struct.ss7*, %struct.ss7** %5
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = ashr i32 %35, 7
%37 = and i32 %36, 1
%38 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load %struct.ss7*, %struct.ss7** %5
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 2
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = and i32 %43, 3
%45 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = load %struct.ss7*, %struct.ss7** %5
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = ashr i32 %50, 2
%52 = and i32 %51, 3
%53 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = load %struct.ss7*, %struct.ss7** %5
%55 = load i8*, i8** %7
%56 = getelementptr inbounds i8, i8* %55, i64 2
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = ashr i32 %58, 4
%60 = and i32 %59, 7
%61 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %54, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%63 = load i8*, i8** %7
%64 = getelementptr inbounds i8, i8* %63, i64 3
%65 = load i32, i32* %8
%66 = sub nsw i32 %65, 3
%67 = load i32, i32* %9
%68 = call i32 @isup_get_number(i8* %62, i8* %64, i32 %66, i32 %67)
%69 = load %struct.ss7*, %struct.ss7** %5
%70 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%71 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %69, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %70)
%72 = load i32, i32* %8
ret i32 %72
}

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