#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*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, char *, char *, char *, char *);
int main() {
  char str1[5][32];
  char *str = "test hello world";
  memset(&str1[0][0], 0x00, sizeof(char) * 5 * 32);
  int ret = sscanf(str, "%s %s %s %s", &str1[0][0], &str1[1][0], &str1[2][0],
                   &str1[3][0]);
  int i;
  for (i = 0; i < 5; i++) {
    printf("str = %s\n", &str1[i][0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1040 <memset@plt>
mov    -0xb8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
add    $0x20,%rcx
lea    -0xb0(%rbp),%r8
add    $0x40,%r8
lea    -0xb0(%rbp),%r9
add    $0x60,%r9
lea    0xe78(%rip),%rsi
call   1050 <sscanf@plt>
mov    %eax,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
cmpl   $0x5,-0xc0(%rbp)
jge    11f0 <main+0xc0>
movslq -0xc0(%rbp),%rax
lea    -0xb0(%rbp),%rsi
shl    $0x5,%rax
add    %rax,%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    11ae <main+0x7e>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    %rsp,%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1040 <memset@plt>
lea    0x20(%rsp),%r14
lea    0x40(%rsp),%r15
lea    0x60(%rsp),%r12
lea    0xe98(%rip),%rdi
lea    0xea2(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %r12,%r9
call   1050 <sscanf@plt>
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
lea    0x80(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"test hello world\00"
@.str.1 = [12 x i8] c"%s %s %s %s\00"
@.str.2 = [10 x i8] c"str = %s\0A\00"
define i32 @main() {
%1 = alloca [5 x [32 x i8]]
%2 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 160)
%4 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 1, i64 0
%5 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 2, i64 0
%6 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 3, i64 0
%7 = call i32 @sscanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %4, i8* %5, i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 4, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
ret i32 0
}