#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 get_resource_size(char *);
int /*<<< orphan*/ printf(char *, int, char *);
scalar_t__ strlen(char *);
void dec_text(char *raw_data) {
  char *cur_data;
  int i = 0;
  int size;
  size = get_resource_size(raw_data);
  cur_data = raw_data;
  while (cur_data - raw_data < size) {
    printf("%d: %s\n", i, cur_data);
    i++;
    cur_data += strlen(cur_data) + 1;
  }
  return;
}


x86 assembly (clang, -O0):
<dec_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_resource_size@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmp    %rcx,%rax
jge    11a5 <dec_text+0x75>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <dec_text+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec_text>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1030 <get_resource_size@plt>
test   %eax,%eax
jle    118a <dec_text+0x5a>
movslq %eax,%r12
xor    %ebp,%ebp
lea    0xeb0(%rip),%r14
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1050 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
sub    %r15,%rax
cmp    %r12,%rax
jl     1160 <dec_text+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d: %s\0A\00"
define void @dec_text(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = call i32 @get_resource_size(i8* %6)
store i32 %7, i32* %5
%8 = load i8*, i8** %2
store i8* %8, i8** %3
br label %9
9: ; preds = %18, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %18, label %29
18: ; preds = %9
%19 = load i32, i32* %4
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %20)
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
%24 = load i8*, i8** %3
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %25, 1
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8* %28, i8** %3
br label %9
29: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d: %s\0A\00"
define void @dec_text(i8* %0) {
%2 = tail call i32 @get_resource_size(i8* %0)
%3 = ptrtoint i8* %0 to i64
%4 = sext i32 %2 to i64
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %17
6: ; preds = %1, %6
%7 = phi i8* [ %13, %6 ], [ %0, %1 ]
%8 = phi i32 [ %10, %6 ], [ 0, %1 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %7)
%10 = add nuw nsw i32 %8, 1
%11 = tail call i64 @strlen(i8* dereferenceable(1) %7)
%12 = add nsw i64 %11, 1
%13 = getelementptr inbounds i8, i8* %7, i64 %12
%14 = ptrtoint i8* %13 to i64
%15 = sub i64 %14, %3
%16 = icmp slt i64 %15, %4
br i1 %16, label %6, label %17
17: ; preds = %6, %1
ret void
}