#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char *);
int strlen(char const *);
char **prefix_stream_urls(int iters, char **stream_urls) {
  const char *insert = "http://";
  unsigned i;
  for (i = 0; i < iters; i++) {
    char *new_str = (char *)malloc(sizeof(char) * strlen(insert) +
                                   strlen(stream_urls[i]) + 1);
    sprintf(new_str, "%s%s", insert, stream_urls[i]);
    free(stream_urls[i]);
    stream_urls[i] = new_str;
  }
  return stream_urls;
}


x86 assembly (clang, -O0):
<prefix_stream_urls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11f7 <prefix_stream_urls+0xb7>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rcx
lea    0xe43(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1161 <prefix_stream_urls+0x21>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prefix_stream_urls>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
test   %edi,%edi
je     11b9 <prefix_stream_urls+0x79>
mov    %edi,%r13d
xor    %ebp,%ebp
lea    0xea2(%rip),%r14
lea    0xea3(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    (%r12,%rbp,8),%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    (%r12,%rbp,8),%rcx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <sprintf@plt>
mov    (%r12,%rbp,8),%rdi
call   1030 <free@plt>
mov    %rbx,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <prefix_stream_urls+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"http://\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8** @prefix_stream_urls(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %48, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %3
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %51
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = load i8**, i8*** %4
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strlen(i8* %21)
%23 = sext i32 %22 to i64
%24 = add i64 %16, %23
%25 = add i64 %24, 1
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %7
%29 = load i8*, i8** %7
%30 = load i8*, i8** %5
%31 = load i8**, i8*** %4
%32 = load i32, i32* %6
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %35)
%37 = load i8**, i8*** %4
%38 = load i32, i32* %6
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @free(i8* %41)
%43 = load i8*, i8** %7
%44 = load i8**, i8*** %4
%45 = load i32, i32* %6
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
store i8* %43, i8** %47
br label %48
48: ; preds = %12
%49 = load i32, i32* %6
%50 = add i32 %49, 1
store i32 %50, i32* %6
br label %8
51: ; preds = %8
%52 = load i8**, i8*** %4
ret i8** %52
}

LLVM IR (-O2):
@.str = [8 x i8] c"http://\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8** @prefix_stream_urls(i32 %0, i8** returned %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %20, %6 ]
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = add i32 %8, 1
%13 = add i32 %12, %11
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = load i8*, i8** %9
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %9
%19 = tail call i32 @free(i8* %18)
store i8* %15, i8** %9
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %6, %2
ret i8** %1
}