#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*/ strncpy(char *, char const *, int);
void test_note(const char *s) {
  extern void sink(void *);
  {
    char a[1][1][2];
    strncpy(a[0][0], s, 3);
    sink(a);
  }
  {
    char a[1][1][2];
    strncpy(a[0][1], s, 3);
    sink(a);
  }
  {
    char a[1][2][2];
    strncpy(a[0][0], s, 3);
    sink(a);
  }
  {
    char a[1][2][2];
    strncpy(a[0][1], s, 3);
    sink(a);
  }
  {
    char a[1][2][2];
    strncpy(a[1][0], s, 3);
    sink(a);
  }
  {
    char a[2][1][2];
    strncpy(a[0][1], s, 3);
    sink(a);
  }
  {
    char a[2][1][2];
    strncpy(a[1][0], s, 3);
    sink(a);
  }
  {
    char a[2][2][3];
    strncpy(a[1][1], s, 4);
    sink(a);
  }
  {
    char a[2][3][3];
    strncpy(a[1][1], s, 5);
    sink(a);
  }
  {
    char a[2][3][3];
    strncpy(a[1][1], s, 6);
    sink(a);
  }
  {
    char a[2][3][3];
    strncpy(a[1][2], s, 7);
    sink(a);
  }
}


x86 assembly (clang, -O0):
<test_note>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xa(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0xa(%rbp),%rdi
call   1040 <sink@plt>
lea    -0xc(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0xc(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x10(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x14(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x14(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x18(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x1c(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x1c(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x20(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x2c(%rbp),%rdi
add    $0x6,%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x2c(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x40(%rbp),%rdi
add    $0x9,%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x40(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x60(%rbp),%rdi
add    $0x9,%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
lea    -0x60(%rbp),%rdi
call   1040 <sink@plt>
lea    -0x80(%rbp),%rdi
add    $0x9,%rdi
add    $0x6,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
lea    -0x80(%rbp),%rdi
call   1040 <sink@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_note>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <sink@plt>
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0x9(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
lea    0xf(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1040 <sink@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @test_note(i8* %0) {
%2 = alloca i8*
%3 = alloca [1 x [1 x [2 x i8]]]
%4 = alloca [1 x [1 x [2 x i8]]]
%5 = alloca [1 x [2 x [2 x i8]]]
%6 = alloca [1 x [2 x [2 x i8]]]
%7 = alloca [1 x [2 x [2 x i8]]]
%8 = alloca [2 x [1 x [2 x i8]]]
%9 = alloca [2 x [1 x [2 x i8]]]
%10 = alloca [2 x [2 x [3 x i8]]]
%11 = alloca [2 x [3 x [3 x i8]]]
%12 = alloca [2 x [3 x [3 x i8]]]
%13 = alloca [2 x [3 x [3 x i8]]]
store i8* %0, i8** %2
%14 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %3, i64 0, i64 0
%15 = getelementptr inbounds [1 x [2 x i8]], [1 x [2 x i8]]* %14, i64 0, i64 0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strncpy(i8* %16, i8* %17, i32 3)
%19 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %3, i64 0, i64 0
%20 = bitcast [1 x [2 x i8]]* %19 to i8*
%21 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %4, i64 0, i64 0
%22 = getelementptr inbounds [1 x [2 x i8]], [1 x [2 x i8]]* %21, i64 0, i64 1
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %22, i64 0, i64 0
%24 = load i8*, i8** %2
%25 = call i32 @strncpy(i8* %23, i8* %24, i32 3)
%26 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %4, i64 0, i64 0
%27 = bitcast [1 x [2 x i8]]* %26 to i8*
%28 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %5, i64 0, i64 0
%29 = getelementptr inbounds [2 x [2 x i8]], [2 x [2 x i8]]* %28, i64 0, i64 0
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %29, i64 0, i64 0
%31 = load i8*, i8** %2
%32 = call i32 @strncpy(i8* %30, i8* %31, i32 3)
%33 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %5, i64 0, i64 0
%34 = bitcast [2 x [2 x i8]]* %33 to i8*
%35 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %6, i64 0, i64 0
%36 = getelementptr inbounds [2 x [2 x i8]], [2 x [2 x i8]]* %35, i64 0, i64 1
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %36, i64 0, i64 0
%38 = load i8*, i8** %2
%39 = call i32 @strncpy(i8* %37, i8* %38, i32 3)
%40 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %6, i64 0, i64 0
%41 = bitcast [2 x [2 x i8]]* %40 to i8*
%42 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %7, i64 0, i64 1
%43 = getelementptr inbounds [2 x [2 x i8]], [2 x [2 x i8]]* %42, i64 0, i64 0
%44 = getelementptr inbounds [2 x i8], [2 x i8]* %43, i64 0, i64 0
%45 = load i8*, i8** %2
%46 = call i32 @strncpy(i8* %44, i8* %45, i32 3)
%47 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %7, i64 0, i64 0
%48 = bitcast [2 x [2 x i8]]* %47 to i8*
%49 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %8, i64 0, i64 0
%50 = getelementptr inbounds [1 x [2 x i8]], [1 x [2 x i8]]* %49, i64 0, i64 1
%51 = getelementptr inbounds [2 x i8], [2 x i8]* %50, i64 0, i64 0
%52 = load i8*, i8** %2
%53 = call i32 @strncpy(i8* %51, i8* %52, i32 3)
%54 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %8, i64 0, i64 0
%55 = bitcast [1 x [2 x i8]]* %54 to i8*
%56 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %9, i64 0, i64 1
%57 = getelementptr inbounds [1 x [2 x i8]], [1 x [2 x i8]]* %56, i64 0, i64 0
%58 = getelementptr inbounds [2 x i8], [2 x i8]* %57, i64 0, i64 0
%59 = load i8*, i8** %2
%60 = call i32 @strncpy(i8* %58, i8* %59, i32 3)
%61 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %9, i64 0, i64 0
%62 = bitcast [1 x [2 x i8]]* %61 to i8*
%63 = getelementptr inbounds [2 x [2 x [3 x i8]]], [2 x [2 x [3 x i8]]]* %10, i64 0, i64 1
%64 = getelementptr inbounds [2 x [3 x i8]], [2 x [3 x i8]]* %63, i64 0, i64 1
%65 = getelementptr inbounds [3 x i8], [3 x i8]* %64, i64 0, i64 0
%66 = load i8*, i8** %2
%67 = call i32 @strncpy(i8* %65, i8* %66, i32 4)
%68 = getelementptr inbounds [2 x [2 x [3 x i8]]], [2 x [2 x [3 x i8]]]* %10, i64 0, i64 0
%69 = bitcast [2 x [3 x i8]]* %68 to i8*
%70 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %11, i64 0, i64 1
%71 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %70, i64 0, i64 1
%72 = getelementptr inbounds [3 x i8], [3 x i8]* %71, i64 0, i64 0
%73 = load i8*, i8** %2
%74 = call i32 @strncpy(i8* %72, i8* %73, i32 5)
%75 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %11, i64 0, i64 0
%76 = bitcast [3 x [3 x i8]]* %75 to i8*
%77 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %12, i64 0, i64 1
%78 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %77, i64 0, i64 1
%79 = getelementptr inbounds [3 x i8], [3 x i8]* %78, i64 0, i64 0
%80 = load i8*, i8** %2
%81 = call i32 @strncpy(i8* %79, i8* %80, i32 6)
%82 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %12, i64 0, i64 0
%83 = bitcast [3 x [3 x i8]]* %82 to i8*
%84 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %13, i64 0, i64 1
%85 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %84, i64 0, i64 2
%86 = getelementptr inbounds [3 x i8], [3 x i8]* %85, i64 0, i64 0
%87 = load i8*, i8** %2
%88 = call i32 @strncpy(i8* %86, i8* %87, i32 7)
%89 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %13, i64 0, i64 0
%90 = bitcast [3 x [3 x i8]]* %89 to i8*
ret void
}

LLVM IR (-O2):
define void @test_note(i8* %0) {
%2 = alloca [1 x [1 x [2 x i8]]]
%3 = alloca [1 x [1 x [2 x i8]]]
%4 = alloca [1 x [2 x [2 x i8]]]
%5 = alloca [1 x [2 x [2 x i8]]]
%6 = alloca [1 x [2 x [2 x i8]]]
%7 = alloca [2 x [1 x [2 x i8]]]
%8 = alloca [2 x [1 x [2 x i8]]]
%9 = alloca [2 x [2 x [3 x i8]]]
%10 = alloca [2 x [3 x [3 x i8]]]
%11 = alloca [2 x [3 x [3 x i8]]]
%12 = alloca [2 x [3 x [3 x i8]]]
%13 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %2, i64 0, i64 0, i64 0, i64 0
%14 = call i32 @strncpy(i8* %13, i8* %0, i32 3)
%15 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %3, i64 0, i64 0, i64 0, i64 0
%16 = getelementptr inbounds [1 x [1 x [2 x i8]]], [1 x [1 x [2 x i8]]]* %3, i64 0, i64 0, i64 1, i64 0
%17 = call i32 @strncpy(i8* %16, i8* %0, i32 3)
%18 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %4, i64 0, i64 0, i64 0, i64 0
%19 = call i32 @strncpy(i8* %18, i8* %0, i32 3)
%20 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %5, i64 0, i64 0, i64 0, i64 0
%21 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %5, i64 0, i64 0, i64 1, i64 0
%22 = call i32 @strncpy(i8* %21, i8* %0, i32 3)
%23 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %6, i64 0, i64 0, i64 0, i64 0
%24 = getelementptr inbounds [1 x [2 x [2 x i8]]], [1 x [2 x [2 x i8]]]* %6, i64 0, i64 1, i64 0, i64 0
%25 = call i32 @strncpy(i8* %24, i8* %0, i32 3)
%26 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %7, i64 0, i64 0, i64 0, i64 0
%27 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %7, i64 0, i64 0, i64 1, i64 0
%28 = call i32 @strncpy(i8* %27, i8* %0, i32 3)
%29 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %8, i64 0, i64 0, i64 0, i64 0
%30 = getelementptr inbounds [2 x [1 x [2 x i8]]], [2 x [1 x [2 x i8]]]* %8, i64 0, i64 1, i64 0, i64 0
%31 = call i32 @strncpy(i8* %30, i8* %0, i32 3)
%32 = getelementptr inbounds [2 x [2 x [3 x i8]]], [2 x [2 x [3 x i8]]]* %9, i64 0, i64 0, i64 0, i64 0
%33 = getelementptr inbounds [2 x [2 x [3 x i8]]], [2 x [2 x [3 x i8]]]* %9, i64 0, i64 1, i64 1, i64 0
%34 = call i32 @strncpy(i8* %33, i8* %0, i32 4)
%35 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %10, i64 0, i64 0, i64 0, i64 0
%36 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %10, i64 0, i64 1, i64 1, i64 0
%37 = call i32 @strncpy(i8* %36, i8* %0, i32 5)
%38 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %11, i64 0, i64 0, i64 0, i64 0
%39 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %11, i64 0, i64 1, i64 1, i64 0
%40 = call i32 @strncpy(i8* %39, i8* %0, i32 6)
%41 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %12, i64 0, i64 0, i64 0, i64 0
%42 = getelementptr inbounds [2 x [3 x [3 x i8]]], [2 x [3 x [3 x i8]]]* %12, i64 0, i64 1, i64 2, i64 0
%43 = call i32 @strncpy(i8* %42, i8* %0, i32 7)
ret void
}