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

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned char);
int /*<<< orphan*/ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_inp_str(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ mpz_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_powm(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 4) {
    printf("Usage: %s modulus e input\n", argv[0]);
    return 0;
  }
  FILE *Nfile = fopen(argv[1], "r");
  FILE *efile = fopen(argv[2], "r");
  FILE *infile = fopen(argv[3], "rb");
  mpz_t N;
  mpz_t e;
  mpz_init(N);
  mpz_init(e);
  mpz_inp_str(N, Nfile, 16);
  mpz_inp_str(e, efile, 16);
  size_t siglen = 1024;
  unsigned char flagme[siglen];
  memset(flagme, 0, siglen);
  flagme[siglen - 6] = 'F';
  flagme[siglen - 5] = 'l';
  flagme[siglen - 4] = 'a';
  flagme[siglen - 3] = 'g';
  flagme[siglen - 2] = 'M';
  flagme[siglen - 1] = 'e';
  mpz_t tmp;
  mpz_init(tmp);
  mpz_t flagme_mpz;
  mpz_init(flagme_mpz);
  for (int i = 0; i < siglen; i++) {
    mpz_mul_ui(tmp, flagme_mpz, 256);
    mpz_add_ui(flagme_mpz, tmp, flagme[i]);
  }
  mpz_t sig;
  mpz_init(sig);
  mpz_inp_str(sig, infile, 16);
  mpz_powm(tmp, sig, e, N);
  if (!mpz_cmp(tmp, flagme_mpz)) {
    printf("MCA-5C8AEC67\n");
  } else
    printf("Not a valid signature of \"FlagMe\".  Request denied.\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11d1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1393 <main+0x203>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3b(%rip),%rsi
mov    %rsi,-0x70(%rbp)
call   10a0 <fopen@plt>
mov    -0x70(%rbp),%rsi
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe0c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x30(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
mov    %edx,-0x64(%rbp)
call   1080 <mpz_inp_str@plt>
mov    -0x64(%rbp),%edx
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1080 <mpz_inp_str@plt>
movq   $0x400,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x60(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x6,%rcx
movb   $0x46,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
sub    $0x5,%rcx
movb   $0x6c,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
sub    $0x4,%rcx
movb   $0x61,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
sub    $0x3,%rcx
movb   $0x67,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
sub    $0x2,%rcx
movb   $0x4d,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x65,(%rax,%rcx,1)
mov    -0x4c(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x50(%rbp),%edi
call   1070 <mpz_init@plt>
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    132d <main+0x19d>
mov    -0x4c(%rbp),%edi
mov    -0x50(%rbp),%esi
mov    $0x100,%edx
call   10b0 <mpz_mul_ui@plt>
mov    -0x60(%rbp),%rax
mov    -0x50(%rbp),%edi
mov    -0x4c(%rbp),%esi
movslq -0x54(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
call   1040 <mpz_add_ui@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12ea <main+0x15a>
mov    -0x58(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x58(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1080 <mpz_inp_str@plt>
mov    -0x4c(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0x4c(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1090 <mpz_cmp@plt>
cmp    $0x0,%eax
jne    137e <main+0x1ee>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    138c <main+0x1fc>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    12ab <main+0x10b>
mov    0x8(%rbx),%rdi
lea    0xe56(%rip),%r14
mov    %r14,%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
call   10b0 <fopen@plt>
mov    %rax,%r12
mov    0x18(%rbx),%rdi
lea    0xe33(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
call   1080 <mpz_init@plt>
call   1080 <mpz_init@plt>
mov    %r15,%rsi
mov    $0x10,%edx
call   1090 <mpz_inp_str@plt>
mov    %r12,%rsi
mov    $0x10,%edx
call   1090 <mpz_inp_str@plt>
mov    %rsp,%r15
mov    %rsp,%r13
lea    -0x400(%r13),%r12
mov    %r12,%rsp
xor    %ebx,%ebx
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
movl   $0x67616c46,-0x6(%r13)
67
movw   $0x654d,-0x2(%r13)
call   1080 <mpz_init@plt>
call   1080 <mpz_init@plt>
mov    $0x100,%edx
call   10c0 <mpz_mul_ui@plt>
movzbl (%r12,%rbx,1),%edx
call   1050 <mpz_add_ui@plt>
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1250 <main+0xb0>
call   1080 <mpz_init@plt>
mov    %r14,%rsi
mov    $0x10,%edx
call   1090 <mpz_inp_str@plt>
call   1030 <mpz_powm@plt>
call   10a0 <mpz_cmp@plt>
test   %eax,%eax
lea    0xd8a(%rip),%rax
lea    0xd90(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r15,%rsp
jmp    12bc <main+0x11c>
mov    (%rbx),%rsi
lea    0xd4b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Usage: %s modulus e input\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [14 x i8] c"MCA-5C8AEC67\0A\00"
@.str.4 = [53 x i8] c"Not a valid signature of \22FlagMe\22. Request denied.\0A\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 i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 4
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 0, i32* %3
br label %115
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %37, i32** %8
%38 = load i32, i32* %9
%39 = call i32 @mpz_init(i32 %38)
%40 = load i32, i32* %10
%41 = call i32 @mpz_init(i32 %40)
%42 = load i32, i32* %9
%43 = load i32*, i32** %6
%44 = call i32 @mpz_inp_str(i32 %42, i32* %43, i32 16)
%45 = load i32, i32* %10
%46 = load i32*, i32** %7
%47 = call i32 @mpz_inp_str(i32 %45, i32* %46, i32 16)
store i64 1024, i64* %11
%48 = load i64, i64* %11
%49 = call i8* @llvm.stacksave()
store i8* %49, i8** %12
%50 = alloca i8, i64 %48
store i64 %48, i64* %13
%51 = load i64, i64* %11
%52 = call i32 @memset(i8* %50, i32 0, i64 %51)
%53 = load i64, i64* %11
%54 = sub i64 %53, 6
%55 = getelementptr inbounds i8, i8* %50, i64 %54
store i8 70, i8* %55
%56 = load i64, i64* %11
%57 = sub i64 %56, 5
%58 = getelementptr inbounds i8, i8* %50, i64 %57
store i8 108, i8* %58
%59 = load i64, i64* %11
%60 = sub i64 %59, 4
%61 = getelementptr inbounds i8, i8* %50, i64 %60
store i8 97, i8* %61
%62 = load i64, i64* %11
%63 = sub i64 %62, 3
%64 = getelementptr inbounds i8, i8* %50, i64 %63
store i8 103, i8* %64
%65 = load i64, i64* %11
%66 = sub i64 %65, 2
%67 = getelementptr inbounds i8, i8* %50, i64 %66
store i8 77, i8* %67
%68 = load i64, i64* %11
%69 = sub i64 %68, 1
%70 = getelementptr inbounds i8, i8* %50, i64 %69
store i8 101, i8* %70
%71 = load i32, i32* %14
%72 = call i32 @mpz_init(i32 %71)
%73 = load i32, i32* %15
%74 = call i32 @mpz_init(i32 %73)
store i32 0, i32* %16
br label %75
75: ; preds = %91, %25
%76 = load i32, i32* %16
%77 = sext i32 %76 to i64
%78 = load i64, i64* %11
%79 = icmp ult i64 %77, %78
br i1 %79, label %80, label %94
80: ; preds = %75
%81 = load i32, i32* %14
%82 = load i32, i32* %15
%83 = call i32 @mpz_mul_ui(i32 %81, i32 %82, i32 256)
%84 = load i32, i32* %15
%85 = load i32, i32* %14
%86 = load i32, i32* %16
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %50, i64 %87
%89 = load i8, i8* %88
%90 = call i32 @mpz_add_ui(i32 %84, i32 %85, i8 zeroext %89)
br label %91
91: ; preds = %80
%92 = load i32, i32* %16
%93 = add nsw i32 %92, 1
store i32 %93, i32* %16
br label %75
94: ; preds = %75
%95 = load i32, i32* %17
%96 = call i32 @mpz_init(i32 %95)
%97 = load i32, i32* %17
%98 = load i32*, i32** %8
%99 = call i32 @mpz_inp_str(i32 %97, i32* %98, i32 16)
%100 = load i32, i32* %14
%101 = load i32, i32* %17
%102 = load i32, i32* %10
%103 = load i32, i32* %9
%104 = call i32 @mpz_powm(i32 %100, i32 %101, i32 %102, i32 %103)
%105 = load i32, i32* %14
%106 = load i32, i32* %15
%107 = call i32 @mpz_cmp(i32 %105, i32 %106)
%108 = icmp ne i32 %107, 0
br i1 %108, label %111, label %109
109: ; preds = %94
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %113
111: ; preds = %94
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %113
113: ; preds = %111, %109
%114 = load i8*, i8** %12
br label %115
115: ; preds = %113, %20
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
@.str = [27 x i8] c"Usage: %s modulus e input\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"rb\00"
@str = [13 x i8] c"MCA-5C8AEC67\00"
@str.5 = [52 x i8] c"Not a valid signature of \22FlagMe\22. Request denied.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %49
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @mpz_init(i32 undef)
%18 = tail call i32 @mpz_init(i32 undef)
%19 = tail call i32 @mpz_inp_str(i32 undef, i32* %10, i32 16)
%20 = tail call i32 @mpz_inp_str(i32 undef, i32* %13, i32 16)
%21 = tail call i8* @llvm.stacksave()
%22 = alloca [1024 x i8]
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i64 1024)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1018
store i8 70, i8* %25
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1019
store i8 108, i8* %26
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1020
store i8 97, i8* %27
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1021
store i8 103, i8* %28
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1022
store i8 77, i8* %29
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 1023
store i8 101, i8* %30
%31 = call i32 @mpz_init(i32 undef)
%32 = call i32 @mpz_init(i32 undef)
br label %41
33: ; preds = %41
%34 = call i32 @mpz_init(i32 undef)
%35 = call i32 @mpz_inp_str(i32 undef, i32* %16, i32 16)
%36 = call i32 @mpz_powm(i32 undef, i32 undef, i32 undef, i32 undef)
%37 = call i32 @mpz_cmp(i32 undef, i32 undef)
%38 = icmp eq i32 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @str.5, i64 0, i64 0)
%40 = call i32 @puts(i8* dereferenceable(1) %39)
br label %49
41: ; preds = %7, %41
%42 = phi i64 [ 0, %7 ], [ %47, %41 ]
%43 = call i32 @mpz_mul_ui(i32 undef, i32 undef, i32 256)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 %42
%45 = load i8, i8* %44
%46 = call i32 @mpz_add_ui(i32 undef, i32 undef, i8 zeroext %45)
%47 = add nuw nsw i64 %42, 1
%48 = icmp eq i64 %47, 1024
br i1 %48, label %33, label %41
49: ; preds = %33, %4
ret i32 0
}