#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
char *dummy_crypt_seed(char *, int, char *, int, int, int);
int dummy_crypt_size_seed(int, int, int);
char *dummy_decrypt_seed(char *, int, char *, int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc <= 2) {
    printf("Usage: %s msg key [n]\n", argv[0]);
    return 1;
  }
  uint32_t no_seed = 0;
  if (argc >= 4) {
    if (argv[3][0] == 'n') {
      no_seed = 1;
    }
  }
  uint32_t seed = 10;
  uint32_t srclen = strlen(argv[1]) + 1;
  uint32_t key_len = strlen(argv[2]);
  char *m = dummy_crypt_seed(argv[1], srclen, argv[2], key_len, seed,
                             no_seed ? 0 : 1);
  uint32_t s = dummy_crypt_size_seed(srclen, seed, no_seed ? 0 : 1);
  printf("Crypted  : ");
  for (uint32_t i = 0; i < s; ++i) {
    printf("%.2X ", (uint8_t)m[i]);
  }
  printf("\n");
  char *p = dummy_decrypt_seed(m, s, argv[2], key_len, no_seed ? seed : 0);
  printf("Decrypted: %s\n", p);
  free(m);
  free(p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     11a1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1326 <main+0x1c6>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     11d2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11cd <main+0x6d>
movl   $0x1,-0x14(%rbp)
jmp    11d2 <main+0x72>
movl   $0xa,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r10d
mov    $0x1,%r9d
xor    %eax,%eax
cmp    $0x0,%r10d
cmovne %eax,%r9d
call   1070 <dummy_crypt_seed@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
call   1080 <dummy_crypt_size_seed@plt>
mov    %eax,-0x2c(%rbp)
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    129a <main+0x13a>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1266 <main+0x106>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12dd <main+0x17d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    12e7 <main+0x187>
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
jmp    12e7 <main+0x187>
mov    -0x3c(%rbp),%ecx
mov    -0x48(%rbp),%rdx
mov    -0x4c(%rbp),%esi
mov    -0x58(%rbp),%rdi
mov    -0x5c(%rbp),%r8d
call   1060 <dummy_decrypt_seed@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
cmp    $0x2,%edi
jg     11a3 <main+0x33>
mov    (%r12),%rsi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%r15d
jmp    129b <main+0x12b>
mov    $0x1,%bl
cmp    $0x3,%edi
je     11b5 <main+0x45>
mov    0x18(%r12),%rax
cmpb   $0x6e,(%rax)
setne  %bl
mov    0x8(%r12),%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%r14d
mov    0x10(%r12),%rdi
call   1050 <strlen@plt>
mov    0x8(%r12),%rdi
mov    0x10(%r12),%rdx
mov    %bl,0xf(%rsp)
movzbl %bl,%ebx
mov    %r14d,%esi
mov    %eax,0x14(%rsp)
mov    %eax,%ecx
mov    $0xa,%r8d
mov    %ebx,%r9d
call   1080 <dummy_crypt_seed@plt>
mov    %rax,%rbp
mov    %r14d,%edi
mov    $0xa,%esi
mov    %ebx,%edx
call   1090 <dummy_crypt_size_seed@plt>
mov    %eax,%ebx
lea    0xe07(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,0x10(%rsp)
test   %ebx,%ebx
jle    1249 <main+0xd9>
mov    0x10(%rsp),%ebx
lea    0xdf6(%rip),%r14
xor    %r13d,%r13d
movsbl 0x0(%rbp,%r13,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r13
cmp    %r13,%rbx
jne    1230 <main+0xc0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x10(%r12),%rdx
cmpb   $0x0,0xf(%rsp)
mov    $0xa,%r8d
cmovne %r15d,%r8d
mov    %rbp,%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%ecx
call   1070 <dummy_decrypt_seed@plt>
mov    %rax,%rbx
lea    0xda8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s msg key [n]\0A\00"
@.str.1 = [12 x i8] c"Crypted : \00"
@.str.2 = [6 x i8] c"%.2X \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [15 x i8] c"Decrypted: %s\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 i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 1, i32* %3
br label %103
21: ; preds = %2
store i32 0, i32* %6
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 4
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 110
br i1 %31, label %32, label %33
32: ; preds = %24
store i32 1, i32* %6
br label %33
33: ; preds = %32, %24
br label %34
34: ; preds = %33, %21
store i32 10, i32* %7
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @strlen(i8* %37)
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %9
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = load i32, i32* %8
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i32, i32* %9
%52 = load i32, i32* %7
%53 = load i32, i32* %6
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i64
%56 = select i1 %54, i32 0, i32 1
%57 = call i8* @dummy_crypt_seed(i8* %46, i32 %47, i8* %50, i32 %51, i32 %52, i32 %56)
store i8* %57, i8** %10
%58 = load i32, i32* %8
%59 = load i32, i32* %7
%60 = load i32, i32* %6
%61 = icmp ne i32 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i32 0, i32 1
%64 = call i32 @dummy_crypt_size_seed(i32 %58, i32 %59, i32 %63)
store i32 %64, i32* %11
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %12
br label %66
66: ; preds = %78, %34
%67 = load i32, i32* %12
%68 = load i32, i32* %11
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %81
70: ; preds = %66
%71 = load i8*, i8** %10
%72 = load i32, i32* %12
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %70
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 1
store i32 %80, i32* %12
br label %66
81: ; preds = %66
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%83 = load i8*, i8** %10
%84 = load i32, i32* %11
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 2
%87 = load i8*, i8** %86
%88 = load i32, i32* %9
%89 = load i32, i32* %6
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %81
%92 = load i32, i32* %7
br label %94
93: ; preds = %81
br label %94
94: ; preds = %93, %91
%95 = phi i32 [ %92, %91 ], [ 0, %93 ]
%96 = call i8* @dummy_decrypt_seed(i8* %83, i32 %84, i8* %87, i32 %88, i32 %95)
store i8* %96, i8** %13
%97 = load i8*, i8** %13
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %97)
%99 = load i8*, i8** %10
%100 = call i32 @free(i8* %99)
%101 = load i8*, i8** %13
%102 = call i32 @free(i8* %101)
br label %103
103: ; preds = %94, %16
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s msg key [n]\0A\00"
@.str.1 = [12 x i8] c"Crypted : \00"
@.str.2 = [6 x i8] c"%.2X \00"
@.str.4 = [15 x i8] c"Decrypted: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %48
7: ; preds = %2
%8 = icmp eq i32 %0, 3
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 110
br label %14
14: ; preds = %9, %7
%15 = phi i1 [ true, %7 ], [ %13, %9 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 1
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @strlen(i8* %21)
%23 = load i8*, i8** %16
%24 = load i8*, i8** %20
%25 = zext i1 %15 to i32
%26 = tail call i8* @dummy_crypt_seed(i8* %23, i32 %19, i8* %24, i32 %22, i32 10, i32 %25)
%27 = tail call i32 @dummy_crypt_size_seed(i32 %19, i32 10, i32 %25)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp sgt i32 %27, 0
br i1 %29, label %30, label %32
30: ; preds = %14
%31 = zext i32 %27 to i64
br label %40
32: ; preds = %40, %14
%33 = tail call i32 @putchar(i32 10)
%34 = load i8*, i8** %20
%35 = select i1 %15, i32 0, i32 10
%36 = tail call i8* @dummy_decrypt_seed(i8* %26, i32 %27, i8* %34, i32 %22, i32 %35)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %36)
%38 = tail call i32 @free(i8* %26)
%39 = tail call i32 @free(i8* %36)
br label %48
40: ; preds = %30, %40
%41 = phi i64 [ 0, %30 ], [ %46, %40 ]
%42 = getelementptr inbounds i8, i8* %26, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = add nuw nsw i64 %41, 1
%47 = icmp eq i64 %46, %31
br i1 %47, label %32, label %40
48: ; preds = %32, %4
%49 = phi i32 [ 1, %4 ], [ 0, %32 ]
ret i32 %49
}