#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 */
char digit2char(unsigned char);
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, ...);
int((cug_interlock_code_dump))(struct ss7 *ss7, int messagetype,
                               unsigned char *parm, int len) {
  char ni[5];
  unsigned short code;
  ni[0] = digit2char(parm[0] >> 4);
  ni[1] = digit2char(parm[0] & 0x0f);
  ni[2] = digit2char(parm[1] >> 4);
  ni[3] = digit2char(parm[1] & 0x0f);
  ni[4] = '\0';
  code = (parm[2] << 8) | parm[3];
  ss7_message(ss7, "\t\t\tNetwork Identify: %s\n", ni);
  ss7_message(ss7, "\t\t\tBinary Code: %d\n", code);
  return 4;
}


x86 assembly (clang, -O0):
<cug_interlock_code_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    $0x4,%eax
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x4,%eax
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,-0x1f(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xf,%eax
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,-0x1e(%rbp)
movb   $0x0,-0x1d(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x18(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %ax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x21(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
movzwl -0x24(%rbp),%edx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    $0x4,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cug_interlock_code_dump>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    (%rdx),%al
shr    $0x4,%al
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,0x3(%rsp)
movzbl (%rbx),%edi
and    $0xf,%edi
call   1040 <digit2char@plt>
mov    %al,0x4(%rsp)
mov    0x1(%rbx),%al
shr    $0x4,%al
movzbl %al,%edi
call   1040 <digit2char@plt>
mov    %al,0x5(%rsp)
movzbl 0x1(%rbx),%edi
and    $0xf,%edi
call   1040 <digit2char@plt>
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
movzwl 0x2(%rbx),%ebx
shl    $0x10,%ebx
bswap  %ebx
lea    0xe7f(%rip),%rsi
lea    0x3(%rsp),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <ss7_message@plt>
lea    0xe82(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <ss7_message@plt>
mov    $0x4,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [25 x i8] c"\09\09\09Network Identify: %s\0A\00"
@.str.1 = [20 x i8] c"\09\09\09Binary Code: %d\0A\00"
define i32 @cug_interlock_code_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 [5 x i8]
%10 = alloca i16
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, 4
%16 = trunc i32 %15 to i8
%17 = call signext i8 @digit2char(i8 zeroext %16)
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
store i8 %17, i8* %18
%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, 15
%24 = trunc i32 %23 to i8
%25 = call signext i8 @digit2char(i8 zeroext %24)
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 1
store i8 %25, i8* %26
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = ashr i32 %30, 4
%32 = trunc i32 %31 to i8
%33 = call signext i8 @digit2char(i8 zeroext %32)
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 2
store i8 %33, i8* %34
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = and i32 %38, 15
%40 = trunc i32 %39 to i8
%41 = call signext i8 @digit2char(i8 zeroext %40)
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 3
store i8 %41, i8* %42
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 4
store i8 0, i8* %43
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 2
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = shl i32 %47, 8
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i64 3
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = or i32 %48, %52
%54 = trunc i32 %53 to i16
store i16 %54, i16* %10
%55 = load %struct.ss7*, %struct.ss7** %5
%56 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%57 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %55, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %56)
%58 = load %struct.ss7*, %struct.ss7** %5
%59 = load i16, i16* %10
%60 = zext i16 %59 to i32
%61 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %58, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %60)
ret i32 4
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [25 x i8] c"\09\09\09Network Identify: %s\0A\00"
@.str.1 = [20 x i8] c"\09\09\09Binary Code: %d\0A\00"
define i32 @cug_interlock_code_dump(%struct.ss7* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = alloca [5 x i8]
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%7 = load i8, i8* %2
%8 = lshr i8 %7, 4
%9 = tail call signext i8 @digit2char(i8 zeroext %8)
store i8 %9, i8* %6
%10 = load i8, i8* %2
%11 = and i8 %10, 15
%12 = tail call signext i8 @digit2char(i8 zeroext %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 1
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %2, i64 1
%15 = load i8, i8* %14
%16 = lshr i8 %15, 4
%17 = tail call signext i8 @digit2char(i8 zeroext %16)
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 2
store i8 %17, i8* %18
%19 = load i8, i8* %14
%20 = and i8 %19, 15
%21 = tail call signext i8 @digit2char(i8 zeroext %20)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 3
store i8 %21, i8* %22
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 4
store i8 0, i8* %23
%24 = getelementptr inbounds i8, i8* %2, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl nuw nsw i32 %26, 8
%28 = getelementptr inbounds i8, i8* %2, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = or i32 %27, %30
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6)
%33 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %31)
ret i32 4
}