#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*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char const *, char *, char *, char *, char *, char *,
                          char *);
int strlen(char const *);
int test(const char *str) {
  int length = strlen(str);
  if (length > 1024)
    return 0;
  char path[1024] = {0};
  char port[1024] = {0};
  char addr[1024] = {0};
  char start[1024] = {0};
  char end[1024] = {0};
  sscanf(str, "http://%15s:%4s/%s/download.ts?from=%s&to=%s", path, port, addr,
         start, end);
  printf("%s\n", path);
  printf("%s\n", port);
  printf("%s\n", addr);
  printf("%s\n", start);
  printf("%s\n", end);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1430,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jle    1174 <test+0x34>
movl   $0x0,-0x4(%rbp)
jmp    1269 <test+0x129>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0xc20(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x1420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    -0x820(%rbp),%rcx
lea    -0xc20(%rbp),%r8
lea    -0x1020(%rbp),%r9
lea    -0x1420(%rbp),%rax
lea    0xdff(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sscanf@plt>
lea    -0x420(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
lea    -0x820(%rbp),%rsi
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
lea    -0xc20(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1020(%rbp),%rsi
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1420(%rbp),%rsi
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1418,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x400,%eax
jg     1231 <test+0xf1>
lea    0x1010(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xc10(%rsp),%r15
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x810(%rsp),%r12
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x410(%rsp),%r13
mov    $0x400,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x10(%rsp),%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbp,(%rsp)
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1060 <sscanf@plt>
lea    0xe33(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"http://%15s:%4s/%s/download.ts?from=%s&to=%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @test(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1024
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 0, i32* %2
br label %38
15: ; preds = %1
%16 = bitcast [1024 x i8]* %5 to i8*
%17 = bitcast [1024 x i8]* %6 to i8*
%18 = bitcast [1024 x i8]* %7 to i8*
%19 = bitcast [1024 x i8]* %8 to i8*
%20 = bitcast [1024 x i8]* %9 to i8*
%21 = load i8*, i8** %3
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%27 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i8* %24, i8* %25, i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %15, %14
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [45 x i8] c"http://%15s:%4s/%s/download.ts?from=%s&to=%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @test(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 1024
br i1 %8, label %21, label %9
9: ; preds = %1
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %12, i8* %13, i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %21
21: ; preds = %1, %9
ret i32 0
}