#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*/ bzero(char *, int);
int /*<<< orphan*/ my_strncpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strlen(char *);
int main(int c, char *argv[]) {
  char ar1[10];
  printf("Hello world!\n");
  bzero(ar1, 10);
  for (long i = 0; i < 1000000; i++) {
    my_strncpy(ar1, argv[0], 10);
    printf("%lu %lu %s\n", i, strlen(ar1), ar1);
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rdi
mov    $0xa,%esi
call   1060 <bzero@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0xf4240,-0x28(%rbp)
jge    11f1 <main+0xa1>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0xa,%edx
call   1050 <my_strncpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x1a(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    -0x1a(%rbp),%rcx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118a <main+0x3a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xe(%rsp),%r12
mov    %r12,%rdi
mov    $0xa,%esi
call   1070 <bzero@plt>
lea    0xe6d(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14),%rsi
mov    %r12,%rdi
mov    $0xa,%edx
call   1060 <my_strncpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
add    $0x1,%rbx
cmp    $0xf4240,%rbx
jne    11a0 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [12 x i8] c"%lu %lu %s\0A\00"
@str = [13 x i8] c"Hello world!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%6 = call i32 @bzero(i8* %4, i32 10)
br label %8
7: ; preds = %8
ret i32 0
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %15, %8 ]
%10 = load i8*, i8** %1
%11 = call i32 @my_strncpy(i8* %4, i8* %10, i32 10)
%12 = call i32 @strlen(i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %9, i32 %12, i8* %4)
%14 = call i32 @sleep(i32 1)
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, 1000000
br i1 %16, label %7, label %8
}