#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*/ sink(char *);
int /*<<< orphan*/ strcat(char *, int /*<<< orphan*/);
int /*<<< orphan*/ string_range(int);
void test_strcat_range(void) {
  char buf[5] = "";
  (strcat((buf), (string_range(0))), sink((buf)));
  (strcat((buf), (string_range(1))), sink((buf)));
  (strcat((buf), (string_range(2))), sink((buf)));
  (strcat((buf), (string_range(3))), sink((buf)));
  (strcat((buf), (string_range(4))), sink((buf)));
  (strcat((buf), (string_range(5))), sink((buf)));
  {
    char buf2[5] = "12";
    (strcat((buf2), (string_range(4))), sink((buf2)));
  }
}


x86 assembly (clang, -O0):
<test_strcat_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1030 <memset@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x48(%rbp)
xor    %edi,%edi
call   1050 <string_range@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x1,%edi
call   1050 <string_range@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x2,%edi
call   1050 <string_range@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x3,%edi
call   1050 <string_range@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x4,%edi
call   1050 <string_range@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x5,%edi
call   1050 <string_range@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0x5(%rbp),%rdi
call   1040 <sink@plt>
mov    0xdc1(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xdbc(%rip),%al
mov    %al,-0x6(%rbp)
lea    -0xa(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1050 <string_range@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <strcat@plt>
lea    -0xa(%rbp),%rdi
call   1040 <sink@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strcat_range>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xor    %edi,%edi
call   1040 <string_range@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
mov    $0x1,%edi
call   1040 <string_range@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
mov    $0x2,%edi
call   1040 <string_range@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
mov    $0x3,%edi
call   1040 <string_range@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
mov    $0x4,%edi
call   1040 <string_range@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
mov    $0x5,%edi
call   1040 <string_range@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
movb   $0x0,0x4(%rsp)
movl   $0x3231,(%rsp)
mov    $0x4,%edi
call   1040 <string_range@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_strcat_range.buf2 = [5 x i8] c"12\00\00\00"
define void @test_strcat_range() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = bitcast [5 x i8]* %1 to i8*
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = call i32 @string_range(i32 0)
%6 = call i32 @strcat(i8* %4, i32 %5)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%8 = call i32 @sink(i8* %7)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%10 = call i32 @string_range(i32 1)
%11 = call i32 @strcat(i8* %9, i32 %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%13 = call i32 @sink(i8* %12)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%15 = call i32 @string_range(i32 2)
%16 = call i32 @strcat(i8* %14, i32 %15)
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%18 = call i32 @sink(i8* %17)
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%20 = call i32 @string_range(i32 3)
%21 = call i32 @strcat(i8* %19, i32 %20)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%23 = call i32 @sink(i8* %22)
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%25 = call i32 @string_range(i32 4)
%26 = call i32 @strcat(i8* %24, i32 %25)
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%28 = call i32 @sink(i8* %27)
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%30 = call i32 @string_range(i32 5)
%31 = call i32 @strcat(i8* %29, i32 %30)
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%33 = call i32 @sink(i8* %32)
%34 = bitcast [5 x i8]* %2 to i8*
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%36 = call i32 @string_range(i32 4)
%37 = call i32 @strcat(i8* %35, i32 %36)
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%39 = call i32 @sink(i8* %38)
ret void
}

LLVM IR (-O2):
@__const.test_strcat_range.buf2 = [5 x i8] c"12\00\00\00"
define void @test_strcat_range() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @string_range(i32 0)
%5 = call i32 @strcat(i8* %3, i32 %4)
%6 = call i32 @sink(i8* %3)
%7 = call i32 @string_range(i32 1)
%8 = call i32 @strcat(i8* %3, i32 %7)
%9 = call i32 @sink(i8* %3)
%10 = call i32 @string_range(i32 2)
%11 = call i32 @strcat(i8* %3, i32 %10)
%12 = call i32 @sink(i8* %3)
%13 = call i32 @string_range(i32 3)
%14 = call i32 @strcat(i8* %3, i32 %13)
%15 = call i32 @sink(i8* %3)
%16 = call i32 @string_range(i32 4)
%17 = call i32 @strcat(i8* %3, i32 %16)
%18 = call i32 @sink(i8* %3)
%19 = call i32 @string_range(i32 5)
%20 = call i32 @strcat(i8* %3, i32 %19)
%21 = call i32 @sink(i8* %3)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%23 = call i32 @string_range(i32 4)
%24 = call i32 @strcat(i8* %22, i32 %23)
%25 = call i32 @sink(i8* %22)
ret void
}