#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 */

/* Variables and functions */
int /*<<< orphan*/ multi_precision_integer(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ skip(int);
void signature_multi_precision_integer(int pub, int len) {
  switch (pub) {
  case 1:
  case 2:
  case 3:
    multi_precision_integer("RSA m^d mod n");
    printf("\t\t-> PKCS-1\n");
    break;
  case 16:
  case 20:
    multi_precision_integer("ElGamal a = g^k mod p");
    multi_precision_integer("ElGamal b = (h - a*x)/k mod p - 1");
    break;
  case 17:
    multi_precision_integer("DSA r");
    multi_precision_integer("DSA s");
    printf("\t\t-> hash(DSA q bits)\n");
    break;
  default:
    printf("\tUnknown signature(pub %d)\n", pub);
    skip(len);
    break;
  }
}


x86 assembly (clang, -O0):
<signature_multi_precision_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     11ce <signature_multi_precision_integer+0x9e>
mov    -0x10(%rbp),%rax
lea    0xea2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee2(%rip),%rdi
call   1050 <multi_precision_integer@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <signature_multi_precision_integer+0xb7>
lea    0xede(%rip),%rdi
call   1050 <multi_precision_integer@plt>
lea    0xee8(%rip),%rdi
call   1050 <multi_precision_integer@plt>
jmp    11e7 <signature_multi_precision_integer+0xb7>
lea    0xef9(%rip),%rdi
call   1050 <multi_precision_integer@plt>
lea    0xef3(%rip),%rdi
call   1050 <multi_precision_integer@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <signature_multi_precision_integer+0xb7>
mov    -0x4(%rbp),%esi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <skip@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signature_multi_precision_integer>:
push   %rbx
mov    %esi,%ebx
mov    %edi,%esi
lea    -0x1(%rsi),%eax
cmp    $0x13,%eax
ja     118f <signature_multi_precision_integer+0x4f>
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeec(%rip),%rdi
call   1060 <multi_precision_integer@plt>
lea    0xf64(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>
lea    0xee1(%rip),%rdi
call   1060 <multi_precision_integer@plt>
lea    0xeeb(%rip),%rdi
pop    %rbx
jmp    1060 <multi_precision_integer@plt>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <skip@plt>
lea    0xeea(%rip),%rdi
call   1060 <multi_precision_integer@plt>
lea    0xee4(%rip),%rdi
call   1060 <multi_precision_integer@plt>
lea    0xefa(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"RSA m^d mod n\00"
@.str.1 = [13 x i8] c"\09\09-> PKCS-1\0A\00"
@.str.2 = [22 x i8] c"ElGamal a = g^k mod p\00"
@.str.3 = [34 x i8] c"ElGamal b = (h - a*x)/k mod p - 1\00"
@.str.4 = [6 x i8] c"DSA r\00"
@.str.5 = [6 x i8] c"DSA s\00"
@.str.6 = [23 x i8] c"\09\09-> hash(DSA q bits)\0A\00"
@.str.7 = [28 x i8] c"\09Unknown signature(pub %d)\0A\00"
define void @signature_multi_precision_integer(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
switch i32 %5, label %16 [
i32 1, label %6
i32 2, label %6
i32 3, label %6
i32 16, label %9
i32 20, label %9
i32 17, label %12
]
6: ; preds = %2, %2, %2
%7 = call i32 @multi_precision_integer(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %21
9: ; preds = %2, %2
%10 = call i32 @multi_precision_integer(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @multi_precision_integer(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %21
12: ; preds = %2
%13 = call i32 @multi_precision_integer(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @multi_precision_integer(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %21
16: ; preds = %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %4
%20 = call i32 @skip(i32 %19)
br label %21
21: ; preds = %16, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"RSA m^d mod n\00"
@.str.2 = [22 x i8] c"ElGamal a = g^k mod p\00"
@.str.3 = [34 x i8] c"ElGamal b = (h - a*x)/k mod p - 1\00"
@.str.4 = [6 x i8] c"DSA r\00"
@.str.5 = [6 x i8] c"DSA s\00"
@.str.7 = [28 x i8] c"\09Unknown signature(pub %d)\0A\00"
@str = [22 x i8] c"\09\09-> hash(DSA q bits)\00"
@str.8 = [12 x i8] c"\09\09-> PKCS-1\00"
define void @signature_multi_precision_integer(i32 %0, i32 %1) {
switch i32 %0, label %13 [
i32 1, label %3
i32 2, label %3
i32 3, label %3
i32 16, label %6
i32 20, label %6
i32 17, label %9
]
3: ; preds = %2, %2, %2
%4 = tail call i32 @multi_precision_integer(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
br label %16
6: ; preds = %2, %2
%7 = tail call i32 @multi_precision_integer(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @multi_precision_integer(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = tail call i32 @multi_precision_integer(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @multi_precision_integer(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %16
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %0)
%15 = tail call i32 @skip(i32 %1)
br label %16
16: ; preds = %13, %9, %6, %3
ret void
}