#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 *, char *, int);
int /*<<< orphan*/ strlcpy(char *, char *, int);
int strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  char a1[48] = "com.letv.tvos.gamecenter:de_service";
  char b1[32] = "com.letv.tvos.gamecenter:de_se";
  char d1[32] = {0};
  strncpy(d1, a1, 32 - 1);
  printf("[%s] vs [%s] = %d\n", d1, a1, strncmp(d1, a1, 32));
  printf("[%s] vs [%s] = %d\n", d1, a1, strncmp(d1, a1, 32 - 1));
  strlcpy(d1, a1, 32);
  printf("[%s] vs [%s] = %d\n", d1, a1, strncmp(d1, a1, 32));
  printf("[%s] vs [%s] = %d\n", d1, a1, strncmp(d1, a1, 32 - 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x30,%edx
call   1070 <memcpy@plt>
mov    0xe9b(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe95(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe92(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1040 <strncmp@plt>
mov    -0xc0(%rbp),%rsi
mov    -0xb8(%rbp),%rdx
mov    %eax,%ecx
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1f,%edx
call   1040 <strncmp@plt>
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    %eax,%ecx
lea    0xdf1(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1080 <strlcpy@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1040 <strncmp@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x98(%rbp),%rdx
mov    %eax,%ecx
lea    0xd9b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1f,%edx
call   1040 <strncmp@plt>
mov    -0x90(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    %eax,%ecx
lea    0xd57(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
lea    0x20(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1040 <strncmp@plt>
lea    0xe88(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f,%edx
call   1040 <strncmp@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1060 <strlcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1040 <strncmp@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f,%edx
call   1040 <strncmp@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a1 = [48 x i8] c"com.letv.tvos.gamecenter:de_service\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b1 = [32 x i8] c"com.letv.tvos.gamecenter:de_se\00\00"
@.str = [19 x i8] c"[%s] vs [%s] = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [48 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [48 x i8]* %6 to i8*
%10 = bitcast [32 x i8]* %7 to i8*
%11 = bitcast [32 x i8]* %8 to i8*
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 31)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%19 = call i32 @strncmp(i8* %17, i8* %18, i32 32)
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i32 %19)
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%22 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%24 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%25 = call i32 @strncmp(i8* %23, i8* %24, i32 31)
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22, i32 %25)
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%29 = call i32 @strlcpy(i8* %27, i8* %28, i32 32)
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%34 = call i32 @strncmp(i8* %32, i8* %33, i32 32)
%35 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31, i32 %34)
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%37 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%39 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%40 = call i32 @strncmp(i8* %38, i8* %39, i32 31)
%41 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %36, i8* %37, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a1 = [48 x i8] c"com.letv.tvos.gamecenter:de_service\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [19 x i8] c"[%s] vs [%s] = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [48 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = call i32 @strncpy(i8* %6, i8* %5, i32 31)
%8 = call i32 @strncmp(i8* %6, i8* %5, i32 32)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %5, i32 %8)
%10 = call i32 @strncmp(i8* %6, i8* %5, i32 31)
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %5, i32 %10)
%12 = call i32 @strlcpy(i8* %6, i8* %5, i32 32)
%13 = call i32 @strncmp(i8* %6, i8* %5, i32 32)
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %5, i32 %13)
%15 = call i32 @strncmp(i8* %6, i8* %5, i32 31)
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %5, i32 %15)
ret i32 0
}