#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((connected_num_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\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):
<connected_num_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    $0x4,%edx
and    $0x7,%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    $0x2,%edx
and    $0x3,%edx
lea    0xe76(%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    0xe6e(%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    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connected_num_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,%ebp
shr    $0x7,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
and    $0x7f,%edx
lea    0xea3(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xea5(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x2,%edx
and    $0x3,%edx
lea    0xea1(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
and    $0x3,%edx
lea    0xe9e(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x2,%rbx
lea    -0x2(%r14),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%ecx
call   1030 <isup_get_number@plt>
lea    0xe87(%rip),%rsi
mov    %r15,%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 = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.2 = [21 x i8] c"\09\09\09Presentation: %x\0A\00"
@.str.3 = [18 x i8] c"\09\09\09Screening: %x\0A\00"
@.str.4 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @connected_num_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, 4
%31 = and i32 %30, 7
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %25, i8* getelementptr inbounds ([23 x i8], [23 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, 2
%39 = and i32 %38, 3
%40 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %33, i8* getelementptr inbounds ([21 x i8], [21 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 = and i32 %45, 3
%47 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %41, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = load i32, i32* %8
%52 = sub nsw i32 %51, 2
%53 = load i32, i32* %9
%54 = call i32 @isup_get_number(i8* %48, i8* %50, i32 %52, i32 %53)
%55 = load %struct.ss7*, %struct.ss7** %5
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%57 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %55, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %56)
%58 = load i32, i32* %8
ret i32 %58
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.2 = [21 x i8] c"\09\09\09Presentation: %x\0A\00"
@.str.3 = [18 x i8] c"\09\09\09Screening: %x\0A\00"
@.str.4 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @connected_num_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, 4
%16 = and i8 %15, 7
%17 = zext i8 %16 to i32
%18 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8, i8* %13
%20 = lshr i8 %19, 2
%21 = and i8 %20, 3
%22 = zext i8 %21 to i32
%23 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i8, i8* %13
%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 ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i8, i8* %2, i64 2
%29 = add nsw i32 %3, -2
%30 = call i32 @isup_get_number(i8* %9, i8* %28, i32 %29, i32 %8)
%31 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %9)
ret i32 %3
}