#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*/ Encrypt(char *, unsigned char *, int, int /*<<< orphan*/,
                           int /*<<< orphan*/, char **);
int /*<<< orphan*/ PrintError(char *);
int /*<<< orphan*/ ReadPublicParameters(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int, char **);
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
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]);
  char *error;
  mpz_t n, u;
  mpz_init(n);
  mpz_init(u);
  ReadPublicParameters(n, u, l, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  Encrypt(argv[3], (unsigned char *)argv[1], l, n, u, &error);
  if (strcmp(error, "success") != 0) {
    PrintError(error);
    return 1;
  }
  mpz_clear(n);
  mpz_clear(u);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11c8 <main+0x48>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1292 <main+0x112>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x28(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x20(%rbp),%rcx
call   1080 <ReadPublicParameters@plt>
mov    -0x20(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1229 <main+0xa9>
mov    -0x20(%rbp),%rdi
call   10a0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    1292 <main+0x112>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    -0x20(%rbp),%r9
call   1060 <Encrypt@plt>
mov    -0x20(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     127b <main+0xfb>
mov    -0x20(%rbp),%rdi
call   10a0 <PrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    1292 <main+0x112>
mov    -0x24(%rbp),%edi
call   1070 <mpz_clear@plt>
mov    -0x28(%rbp),%edi
call   1070 <mpz_clear@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     11a5 <main+0x25>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe62(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1209 <main+0x89>
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
call   1030 <mpz_init@plt>
call   1030 <mpz_init@plt>
mov    %rsp,%rcx
mov    %ebp,%edx
call   1080 <ReadPublicParameters@plt>
mov    (%rsp),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1200 <main+0x80>
mov    0x8(%rbx),%rsi
mov    0x18(%rbx),%rdi
mov    %rsp,%r9
mov    %ebp,%edx
call   1060 <Encrypt@plt>
mov    (%rsp),%rdi
lea    0xe35(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1215 <main+0x95>
mov    (%rsp),%rdi
call   10a0 <PrintError@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
call   1070 <mpz_clear@plt>
call   1070 <mpz_clear@plt>
xor    %eax,%eax
jmp    120e <main+0x8e>

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"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %59
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i32, i32* %8
%24 = call i32 @mpz_init(i32 %23)
%25 = load i32, i32* %9
%26 = call i32 @mpz_init(i32 %25)
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = call i32 @ReadPublicParameters(i32 %27, i32 %28, i32 %29, i8** %7)
%31 = load i8*, i8** %7
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %18
%35 = load i8*, i8** %7
%36 = call i32 @PrintError(i8* %35)
store i32 1, i32* %3
br label %59
37: ; preds = %18
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = load i32, i32* %6
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = call i32 @Encrypt(i8* %40, i8* %43, i32 %44, i32 %45, i32 %46, i8** %7)
%48 = load i8*, i8** %7
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %37
%52 = load i8*, i8** %7
%53 = call i32 @PrintError(i8* %52)
store i32 1, i32* %3
br label %59
54: ; preds = %37
%55 = load i32, i32* %8
%56 = call i32 @mpz_clear(i32 %55)
%57 = load i32, i32* %9
%58 = call i32 @mpz_clear(i32 %57)
store i32 0, i32* %3
br label %59
59: ; preds = %54, %51, %34, %12
%60 = load i32, i32* %3
ret i32 %60
}

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"
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 %40
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 = call i32 @ReadPublicParameters(i32 undef, i32 undef, i32 %12, i8** %3)
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %9
%21 = load i8*, i8** %3
%22 = call i32 @PrintError(i8* %21)
br label %38
23: ; preds = %9
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @Encrypt(i8* %25, i8* %27, i32 %12, i32 undef, i32 undef, i8** %3)
%29 = load i8*, i8** %3
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %23
%33 = load i8*, i8** %3
%34 = call i32 @PrintError(i8* %33)
br label %38
35: ; preds = %23
%36 = call i32 @mpz_clear(i32 undef)
%37 = call i32 @mpz_clear(i32 undef)
br label %38
38: ; preds = %35, %32, %20
%39 = phi i32 [ 1, %20 ], [ 1, %32 ], [ 0, %35 ]
br label %40
40: ; preds = %38, %5
%41 = phi i32 [ 1, %5 ], [ %39, %38 ]
ret i32 %41
}