#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*/ KeyGen(unsigned char *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/, int, char **);
int /*<<< orphan*/ PrintError(char *);
int /*<<< orphan*/ ReadPrivateParameters(int /*<<< orphan*/, int /*<<< orphan*/,
                                         char **);
int /*<<< orphan*/ ReadPublicParameters(int /*<<< orphan*/, int /*<<< orphan*/,
                                        char **);
int /*<<< orphan*/ WritePrivateParametersToFile(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 < 3) {
    fprintf(stderr, "Usage: %s <identity> <l>\n", argv[0]);
    return 1;
  }
  int l = atoi(argv[2]), i;
  char *error;
  mpz_t n, u, p, q;
  mpz_t *rj;
  mpz_init(n);
  mpz_init(u);
  mpz_init(p);
  mpz_init(q);
  rj = (mpz_t *)malloc(l * sizeof(mpz_t));
  if (rj == NULL) {
    PrintError("malloc error");
    return 1;
  }
  ReadPublicParameters(n, u, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  ReadPrivateParameters(p, q, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  KeyGen((unsigned char *)argv[1], rj, n, u, p, q, l, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  WritePrivateParametersToFile(rj, l, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  for (i = 0; i < l; i++) {
    mpz_clear(rj[i]);
  }
  free(rj);
  mpz_clear(n);
  mpz_clear(u);
  mpz_clear(p);
  mpz_clear(q);
  return 0;
}


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   $0x3,-0x8(%rbp)
jge    1208 <main+0x48>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe09(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x28(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x2c(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x30(%rbp),%edi
call   1070 <mpz_init@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    126e <main+0xae>
lea    0xdbd(%rip),%rdi
call   10e0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   10c0 <ReadPublicParameters@plt>
mov    -0x20(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12ac <main+0xec>
mov    -0x20(%rbp),%rdi
call   10e0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <ReadPrivateParameters@plt>
mov    -0x20(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12ea <main+0x12a>
mov    -0x20(%rbp),%rdi
call   10e0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x14(%rbp),%r10d
lea    -0x20(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <KeyGen@plt>
mov    -0x20(%rbp),%rdi
lea    0xd02(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1349 <main+0x189>
mov    -0x20(%rbp),%rdi
call   10e0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1060 <WritePrivateParametersToFile@plt>
mov    -0x20(%rbp),%rdi
lea    0xcc3(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1388 <main+0x1c8>
mov    -0x20(%rbp),%rdi
call   10e0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e9 <main+0x229>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13b9 <main+0x1f9>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10b0 <mpz_clear@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    138f <main+0x1cf>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x28(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x30(%rbp),%edi
call   10b0 <mpz_clear@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     11ed <main+0x2d>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe1d(%rip),%rsi
call   1090 <fprintf@plt>
jmp    12c1 <main+0x101>
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
lea    0x0(,%r14,4),%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12b5 <main+0xf5>
mov    %rax,%r15
mov    %rsp,%rdx
call   10c0 <ReadPublicParameters@plt>
mov    (%rsp),%rdi
lea    0xdee(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12af <main+0xef>
mov    %rsp,%r12
mov    %r12,%rdx
call   1040 <ReadPrivateParameters@plt>
mov    (%rsp),%rdi
lea    0xdce(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12af <main+0xef>
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
push   %r12
push   %r14
call   1050 <KeyGen@plt>
add    $0x10,%rsp
mov    (%rsp),%rdi
lea    0xda5(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12af <main+0xef>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <WritePrivateParametersToFile@plt>
mov    (%rsp),%rdi
lea    0xd82(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12d2 <main+0x112>
mov    (%rsp),%rdi
jmp    12bc <main+0xfc>
lea    0xd5e(%rip),%rdi
call   10e0 <PrintError@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
test   %r14d,%r14d
jle    12ee <main+0x12e>
mov    %r14d,%r14d
xor    %ebx,%ebx
mov    (%r15,%rbx,4),%edi
call   10b0 <mpz_clear@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    12dc <main+0x11c>
mov    %r15,%rdi
call   1030 <free@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
xor    %eax,%eax
jmp    12c6 <main+0x106>

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

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