#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 */

/* Variables and functions */
int /*<<< orphan*/ decrpyt_buf(char *, char **, int);
int /*<<< orphan*/ encrpyt_buf(char *, char **, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *padding_buf(char *, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printf_buff(char *, int);
int main(int argn, char *argv[]) {
  char *raw_buf = NULL;
  char *after_padding_buf = NULL;
  int padding_size = 0;
  char *encrypt_buf = NULL;
  char *decrypt_buf = NULL;
  raw_buf = (char *)malloc(17);
  memcpy(raw_buf, "life's a struggle", 17);
  printf("------------------raw_buf\n");
  printf_buff(raw_buf, 17);
  after_padding_buf = padding_buf(raw_buf, 17, &padding_size);
  printf("------------------after_padding_buf\n");
  printf_buff(after_padding_buf, padding_size);
  encrypt_buf = (char *)malloc(padding_size);
  encrpyt_buf(after_padding_buf, &encrypt_buf, padding_size);
  printf("------------------encrypt_buf\n");
  printf_buff(encrypt_buf, padding_size);
  decrypt_buf = (char *)malloc(padding_size);
  decrpyt_buf(encrypt_buf, &decrypt_buf, padding_size);
  printf("------------------decrypt_buf\n");
  printf_buff(decrypt_buf, padding_size);
  free(raw_buf);
  free(after_padding_buf);
  free(encrypt_buf);
  free(decrypt_buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x11,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x11,%edx
call   1070 <memcpy@plt>
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x11,%esi
call   10a0 <printf_buff@plt>
mov    -0x18(%rbp),%rdi
mov    $0x11,%esi
lea    -0x24(%rbp),%rdx
call   1040 <padding_buf@plt>
mov    %rax,-0x20(%rbp)
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10a0 <printf_buff@plt>
mov    -0x24(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1060 <encrpyt_buf@plt>
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10a0 <printf_buff@plt>
mov    -0x24(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    -0x38(%rbp),%rsi
call   1080 <decrpyt_buf@plt>
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10a0 <printf_buff@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
mov    $0x11,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe5d(%rip),%rsi
mov    %rax,%rdi
mov    $0x11,%edx
call   1070 <memcpy@plt>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
call   10a0 <printf_buff@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x11,%esi
call   1050 <padding_buf@plt>
mov    %rax,%r14
lea    0xe47(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   10a0 <printf_buff@plt>
mov    0x4(%rsp),%edi
call   1090 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    0x4(%rsp),%edx
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1060 <encrpyt_buf@plt>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
call   10a0 <printf_buff@plt>
mov    0x4(%rsp),%edi
call   1090 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
call   1080 <decrpyt_buf@plt>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%rdi
mov    0x4(%rsp),%esi
call   10a0 <printf_buff@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"life's a struggle\00"
@.str.1 = [27 x i8] c"------------------raw_buf\0A\00"
@.str.2 = [37 x i8] c"------------------after_padding_buf\0A\00"
@.str.3 = [31 x i8] c"------------------encrypt_buf\0A\00"
@.str.4 = [31 x i8] c"------------------decrypt_buf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
store i8* null, i8** %9
store i8* null, i8** %10
%11 = call i64 @malloc(i32 17)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32 @memcpy(i8* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 17)
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %6
%17 = call i32 @printf_buff(i8* %16, i32 17)
%18 = load i8*, i8** %6
%19 = call i8* @padding_buf(i8* %18, i32 17, i32* %8)
store i8* %19, i8** %7
%20 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%21 = load i8*, i8** %7
%22 = load i32, i32* %8
%23 = call i32 @printf_buff(i8* %21, i32 %22)
%24 = load i32, i32* %8
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %9
%27 = load i8*, i8** %7
%28 = load i32, i32* %8
%29 = call i32 @encrpyt_buf(i8* %27, i8** %9, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%31 = load i8*, i8** %9
%32 = load i32, i32* %8
%33 = call i32 @printf_buff(i8* %31, i32 %32)
%34 = load i32, i32* %8
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %10
%37 = load i8*, i8** %9
%38 = load i32, i32* %8
%39 = call i32 @decrpyt_buf(i8* %37, i8** %10, i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%41 = load i8*, i8** %10
%42 = load i32, i32* %8
%43 = call i32 @printf_buff(i8* %41, i32 %42)
%44 = load i8*, i8** %6
%45 = call i32 @free(i8* %44)
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %9
%49 = call i32 @free(i8* %48)
%50 = load i8*, i8** %10
%51 = call i32 @free(i8* %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"life's a struggle\00"
@str = [26 x i8] c"------------------raw_buf\00"
@str.5 = [36 x i8] c"------------------after_padding_buf\00"
@str.6 = [30 x i8] c"------------------encrypt_buf\00"
@str.7 = [30 x i8] c"------------------decrypt_buf\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i8** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = tail call i64 @malloc(i32 17)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @memcpy(i8* %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 17)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @printf_buff(i8* %10, i32 17)
%14 = call i8* @padding_buf(i8* %10, i32 17, i32* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @printf_buff(i8* %14, i32 %16)
%18 = load i32, i32* %3
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %4
%21 = load i32, i32* %3
%22 = call i32 @encrpyt_buf(i8* %14, i8** %4, i32 %21)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.6, i64 0, i64 0))
%24 = load i8*, i8** %4
%25 = load i32, i32* %3
%26 = call i32 @printf_buff(i8* %24, i32 %25)
%27 = load i32, i32* %3
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %5
%30 = load i8*, i8** %4
%31 = load i32, i32* %3
%32 = call i32 @decrpyt_buf(i8* %30, i8** %5, i32 %31)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0))
%34 = load i8*, i8** %5
%35 = load i32, i32* %3
%36 = call i32 @printf_buff(i8* %34, i32 %35)
%37 = call i32 @free(i8* %10)
%38 = call i32 @free(i8* %14)
%39 = load i8*, i8** %4
%40 = call i32 @free(i8* %39)
%41 = load i8*, i8** %5
%42 = call i32 @free(i8* %41)
ret i32 0
}