#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 */
char *advanceToEmbeddingArea(unsigned char *);
char *embedChar(char *, unsigned char);
char *embedInt(char *, int);
void embedStego(unsigned char *ppm, unsigned char *message, int message_len) {
  char *ptr = advanceToEmbeddingArea(ppm);
  ptr = embedInt(ptr, message_len);
  for (int i = 0; i < message_len; i++) {
    ptr = embedChar(ptr, message[i]);
  }
}


x86 assembly (clang, -O0):
<embedStego>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <advanceToEmbeddingArea@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <embedInt@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119a <embedStego+0x6a>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
call   1040 <embedChar@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <embedStego+0x37>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<embedStego>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
call   1030 <advanceToEmbeddingArea@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1050 <embedInt@plt>
test   %ebp,%ebp
jle    1166 <embedStego+0x36>
mov    %ebp,%ebp
xor    %ebx,%ebx
movzbl (%r14,%rbx,1),%esi
mov    %rax,%rdi
call   1040 <embedChar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <embedStego+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @embedStego(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i8* @advanceToEmbeddingArea(i8* %9)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = load i32, i32* %6
%13 = call i8* @embedInt(i8* %11, i32 %12)
store i8* %13, i8** %7
store i32 0, i32* %8
br label %14
14: ; preds = %26, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i8*, i8** %7
%20 = load i8*, i8** %5
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i8* @embedChar(i8* %19, i8 zeroext %24)
store i8* %25, i8** %7
br label %26
26: ; preds = %18
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %14
29: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @embedStego(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i8* @advanceToEmbeddingArea(i8* %0)
%5 = tail call i8* @embedInt(i8* %4, i32 %2)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %10
9: ; preds = %10, %3
ret void
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %16, %10 ]
%12 = phi i8* [ %5, %7 ], [ %15, %10 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %11
%14 = load i8, i8* %13
%15 = tail call i8* @embedChar(i8* %12, i8 zeroext %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %9, label %10
}