#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*/ pad_pkcs(char *, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char input[20] = "YELLOW SUBMARINE";
  char expected_output[20] = "YELLOW SUBMARINE\x4\x4\x4\x4";
  int result = 0;
  pad_pkcs(input, 20, 16, 7, 20);
  for (unsigned int i = 0; i < 20; ++i) {
    printf("%c", input[i]);
    if (input[i] != expected_output[i]) {
      result = -1;
      break;
    }
  }
  if (result == 0) {
    printf("\nSuccess!\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec6(%rip),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x44(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x14,%r8d
mov    $0x10,%edx
mov    $0x7,%ecx
mov    %r8d,%esi
call   1040 <pad_pkcs@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x14,-0x48(%rbp)
jae    11ee <main+0xce>
mov    -0x48(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
mov    -0x48(%rbp),%ecx
movsbl -0x40(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11db <main+0xbb>
movl   $0xffffffff,-0x44(%rbp)
jmp    11ee <main+0xce>
jmp    11e0 <main+0xc0>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1197 <main+0x77>
cmpl   $0x0,-0x44(%rbp)
jne    1206 <main+0xe6>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x14,%esi
mov    $0x10,%edx
mov    $0x7,%ecx
mov    $0x14,%r8d
call   1050 <pad_pkcs@plt>
xor    %ebx,%ebx
lea    0xeb0(%rip),%r14
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movzbl (%rsp,%rbx,1),%eax
cmp    (%rbx,%r14,1),%al
jne    1199 <main+0x69>
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1170 <main+0x40>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.input = [20 x i8] c"YELLOW SUBMARINE\00\00\00\00"
@__const.main.expected_output = [20 x i8] c"YELLOW SUBMARINE\04\04\04\04"
@.str = [3 x i8] c"%c\00"
@.str.1 = [11 x i8] c"\0ASuccess!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [20 x i8]* %2 to i8*
%7 = bitcast [20 x i8]* %3 to i8*
store i32 0, i32* %4
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 @pad_pkcs(i8* %8, i32 20, i32 16, i32 7, i32 20)
store i32 0, i32* %5
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %5
%12 = icmp ult i32 %11, 20
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i32, i32* %5
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %24, %29
br i1 %30, label %31, label %32
31: ; preds = %13
store i32 -1, i32* %4
br label %36
32: ; preds = %13
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %10
36: ; preds = %31, %10
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@__const.main.input = [20 x i8] c"YELLOW SUBMARINE\00\00\00\00"
@__const.main.expected_output = [20 x i8] c"YELLOW SUBMARINE\04\04\04\04"
@str = [10 x i8] c"\0ASuccess!\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i32 @pad_pkcs(i8* %2, i32 20, i32 16, i32 7, i32 20)
br label %7
4: ; preds = %7
%5 = add nuw nsw i64 %8, 1
%6 = icmp eq i64 %5, 20
br i1 %6, label %17, label %7
7: ; preds = %0, %4
%8 = phi i64 [ 0, %0 ], [ %5, %4 ]
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 @putchar(i32 %11)
%13 = load i8, i8* %9
%14 = getelementptr inbounds [20 x i8], [20 x i8]* @__const.main.expected_output, i64 0, i64 %8
%15 = load i8, i8* %14
%16 = icmp eq i8 %13, %15
br i1 %16, label %4, label %19
17: ; preds = %4
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %7, %17
ret i32 0
}