#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ Decrypt(char *, char *, int, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ PrintError(char *);
int /*<<< orphan*/ ReadPrivateParameters(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/ *, int, char **);
int /*<<< orphan*/ ReadPublicParameters(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int, char **);
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 4) {
    fprintf(stderr, "Usage: %s <identity> <l> <plaintext_file>\n", argv[0]);
    return 1;
  }
  int l = atoi(argv[2]), i;
  char *error;
  mpz_t *r, n, u, p, q;
  mpz_init(n);
  mpz_init(u);
  mpz_init(p);
  mpz_init(q);
  ReadPublicParameters(n, u, l, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  r = (mpz_t *)malloc(l * sizeof(mpz_t));
  if (r == NULL) {
    PrintError("malloc");
    return 1;
  }
  ReadPrivateParameters(p, q, r, l, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  Decrypt(argv[3], argv[1], l, p, q, n, u, r, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  for (i = 0; i < l; i++)
    mpz_clear(r[i]);
  free(r);
  mpz_clear(n);
  mpz_clear(u);
  mpz_clear(p);
  mpz_clear(q);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11f8 <main+0x48>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13aa <main+0x1fa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x30(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x34(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x38(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x20(%rbp),%rcx
call   10b0 <ReadPublicParameters@plt>
mov    -0x20(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1269 <main+0xb9>
mov    -0x20(%rbp),%rdi
call   10d0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13aa <main+0x1fa>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129f <main+0xef>
lea    0xda5(%rip),%rdi
call   10d0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13aa <main+0x1fa>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x20(%rbp),%r8
call   1040 <ReadPrivateParameters@plt>
mov    -0x20(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12e4 <main+0x134>
mov    -0x20(%rbp),%rdi
call   10d0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13aa <main+0x1fa>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r11d
mov    -0x28(%rbp),%r10
lea    -0x20(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1090 <Decrypt@plt>
mov    -0x20(%rbp),%rdi
lea    0xcff(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1350 <main+0x1a0>
mov    -0x20(%rbp),%rdi
call   10d0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13aa <main+0x1fa>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1381 <main+0x1d1>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10a0 <mpz_clear@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1357 <main+0x1a7>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x30(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x34(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x38(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     11dd <main+0x2d>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe2a(%rip),%rsi
call   1070 <fprintf@plt>
jmp    122a <main+0x7a>
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
lea    0x20(%rsp),%rcx
mov    %r14d,%edx
call   10b0 <ReadPublicParameters@plt>
mov    0x20(%rsp),%rdi
lea    0xe15(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     123b <main+0x8b>
mov    0x20(%rsp),%rdi
call   10d0 <PrintError@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     12f5 <main+0x145>
mov    %rax,%r15
lea    0x20(%rsp),%r12
mov    %rax,%rdx
mov    %r14d,%ecx
mov    %r12,%r8
call   1040 <ReadPrivateParameters@plt>
mov    0x20(%rsp),%rdi
lea    0xdb8(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1220 <main+0x70>
mov    0x8(%rbx),%rsi
mov    0x18(%rbx),%rdi
mov    %r12,0x10(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14d,%edx
call   1090 <Decrypt@plt>
mov    0x20(%rsp),%rdi
lea    0xd88(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1220 <main+0x70>
test   %r14d,%r14d
jle    12d2 <main+0x122>
mov    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%edi
call   10a0 <mpz_clear@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    12c0 <main+0x110>
mov    %r15,%rdi
call   1030 <free@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
xor    %eax,%eax
jmp    122f <main+0x7f>
lea    0xd37(%rip),%rdi
jmp    1225 <main+0x75>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Usage: %s <identity> <l> <plaintext_file>\0A\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [7 x i8] c"malloc\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %114
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %10
%28 = call i32 @mpz_init(i32 %27)
%29 = load i32, i32* %11
%30 = call i32 @mpz_init(i32 %29)
%31 = load i32, i32* %12
%32 = call i32 @mpz_init(i32 %31)
%33 = load i32, i32* %13
%34 = call i32 @mpz_init(i32 %33)
%35 = load i32, i32* %10
%36 = load i32, i32* %11
%37 = load i32, i32* %6
%38 = call i32 @ReadPublicParameters(i32 %35, i32 %36, i32 %37, i8** %8)
%39 = load i8*, i8** %8
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %22
%43 = load i8*, i8** %8
%44 = call i32 @PrintError(i8* %43)
store i32 1, i32* %3
br label %114
45: ; preds = %22
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 4
%49 = trunc i64 %48 to i32
%50 = call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to i32*
store i32* %51, i32** %9
%52 = load i32*, i32** %9
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %56
54: ; preds = %45
%55 = call i32 @PrintError(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %114
56: ; preds = %45
%57 = load i32, i32* %12
%58 = load i32, i32* %13
%59 = load i32*, i32** %9
%60 = load i32, i32* %6
%61 = call i32 @ReadPrivateParameters(i32 %57, i32 %58, i32* %59, i32 %60, i8** %8)
%62 = load i8*, i8** %8
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %56
%66 = load i8*, i8** %8
%67 = call i32 @PrintError(i8* %66)
store i32 1, i32* %3
br label %114
68: ; preds = %56
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 3
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = load i32, i32* %6
%76 = load i32, i32* %12
%77 = load i32, i32* %13
%78 = load i32, i32* %10
%79 = load i32, i32* %11
%80 = load i32*, i32** %9
%81 = call i32 @Decrypt(i8* %71, i8* %74, i32 %75, i32 %76, i32 %77, i32 %78, i32 %79, i32* %80, i8** %8)
%82 = load i8*, i8** %8
%83 = call i64 @strcmp(i8* %82, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %68
%86 = load i8*, i8** %8
%87 = call i32 @PrintError(i8* %86)
store i32 1, i32* %3
br label %114
88: ; preds = %68
store i32 0, i32* %7
br label %89
89: ; preds = %100, %88
%90 = load i32, i32* %7
%91 = load i32, i32* %6
%92 = icmp slt i32 %90, %91
br i1 %92, label %93, label %103
93: ; preds = %89
%94 = load i32*, i32** %9
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
%98 = load i32, i32* %97
%99 = call i32 @mpz_clear(i32 %98)
br label %100
100: ; preds = %93
%101 = load i32, i32* %7
%102 = add nsw i32 %101, 1
store i32 %102, i32* %7
br label %89
103: ; preds = %89
%104 = load i32*, i32** %9
%105 = call i32 @free(i32* %104)
%106 = load i32, i32* %10
%107 = call i32 @mpz_clear(i32 %106)
%108 = load i32, i32* %11
%109 = call i32 @mpz_clear(i32 %108)
%110 = load i32, i32* %12
%111 = call i32 @mpz_clear(i32 %110)
%112 = load i32, i32* %13
%113 = call i32 @mpz_clear(i32 %112)
br label %114
114: ; preds = %103, %85, %65, %54, %42, %16
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Usage: %s <identity> <l> <plaintext_file>\0A\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [7 x i8] c"malloc\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp slt i32 %0, 4
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %71
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = bitcast i8** %3 to i8*
%14 = tail call i32 @mpz_init(i32 undef)
%15 = tail call i32 @mpz_init(i32 undef)
%16 = tail call i32 @mpz_init(i32 undef)
%17 = tail call i32 @mpz_init(i32 undef)
%18 = call i32 @ReadPublicParameters(i32 undef, i32 undef, i32 %12, i8** %3)
%19 = load i8*, i8** %3
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %9
%23 = load i8*, i8** %3
%24 = call i32 @PrintError(i8* %23)
br label %69
25: ; preds = %9
%26 = shl i32 %12, 2
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i32*
%29 = icmp eq i64 %27, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @PrintError(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %69
32: ; preds = %25
%33 = call i32 @ReadPrivateParameters(i32 undef, i32 undef, i32* %28, i32 %12, i8** %3)
%34 = load i8*, i8** %3
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i32 @PrintError(i8* %38)
br label %69
40: ; preds = %32
%41 = getelementptr inbounds i8*, i8** %1, i64 3
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8*, i8** %1, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @Decrypt(i8* %42, i8* %44, i32 %12, i32 undef, i32 undef, i32 undef, i32 undef, i32* %28, i8** %3)
%46 = load i8*, i8** %3
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %40
%50 = icmp sgt i32 %12, 0
br i1 %50, label %51, label %63
51: ; preds = %49
%52 = zext i32 %12 to i64
br label %56
53: ; preds = %40
%54 = load i8*, i8** %3
%55 = call i32 @PrintError(i8* %54)
br label %69
56: ; preds = %51, %56
%57 = phi i64 [ 0, %51 ], [ %61, %56 ]
%58 = getelementptr inbounds i32, i32* %28, i64 %57
%59 = load i32, i32* %58
%60 = call i32 @mpz_clear(i32 %59)
%61 = add nuw nsw i64 %57, 1
%62 = icmp eq i64 %61, %52
br i1 %62, label %63, label %56
63: ; preds = %56, %49
%64 = call i32 @free(i32* %28)
%65 = call i32 @mpz_clear(i32 undef)
%66 = call i32 @mpz_clear(i32 undef)
%67 = call i32 @mpz_clear(i32 undef)
%68 = call i32 @mpz_clear(i32 undef)
br label %69
69: ; preds = %63, %53, %37, %30, %22
%70 = phi i32 [ 1, %22 ], [ 1, %30 ], [ 1, %37 ], [ 1, %53 ], [ 0, %63 ]
br label %71
71: ; preds = %69, %5
%72 = phi i32 [ 1, %5 ], [ %70, %69 ]
ret i32 %72
}