void test_binary_extensions(void) {
  char buf[][20] = {
      "archive.tar.gz",
      "photos.tar.bz2",
  };
  do {
    seatest_assert_string_equal("tar.gz", cut_extension(buf[0]), __FUNCTION__,
                                38);
  } while (0);
  do {
    seatest_assert_string_equal("archive", buf[0], __FUNCTION__, 39);
  } while (0);
  do {
    seatest_assert_string_equal("tar.bz2", cut_extension(buf[1]), __FUNCTION__,
                                40);
  } while (0);
  do {
    seatest_assert_string_equal("photos", buf[1], __FUNCTION__, 41);
  } while (0);
}


x86 assembly (clang, -O0):
<test_binary_extensions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x30(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x28,%edx
call   1030 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1050 <cut_extension@plt>
mov    %eax,%esi
lea    0xec7(%rip),%rdi
lea    0xec7(%rip),%rdx
mov    $0x26,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
jmp    1179 <test_binary_extensions+0x49>
lea    -0x30(%rbp),%rsi
lea    0xec2(%rip),%rdi
lea    0xea4(%rip),%rdx
mov    $0x27,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
jmp    119c <test_binary_extensions+0x6c>
lea    -0x30(%rbp),%rdi
add    $0x14,%rdi
mov    $0x0,%al
call   1050 <cut_extension@plt>
mov    %eax,%esi
lea    0xe9a(%rip),%rdi
lea    0xe74(%rip),%rdx
mov    $0x28,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
jmp    11cc <test_binary_extensions+0x9c>
lea    -0x30(%rbp),%rsi
add    $0x14,%rsi
lea    0xe7b(%rip),%rdi
lea    0xe4d(%rip),%rdx
mov    $0x29,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_binary_extensions>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xef2(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <cut_extension@plt>
lea    0xeca(%rip),%rdi
lea    0xeca(%rip),%rbx
mov    %eax,%esi
mov    %rbx,%rdx
mov    $0x26,%ecx
xor    %eax,%eax
call   1030 <seatest_assert_string_equal@plt>
lea    0xec9(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x27,%ecx
xor    %eax,%eax
call   1030 <seatest_assert_string_equal@plt>
lea    0x14(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <cut_extension@plt>
lea    0xea9(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
mov    $0x28,%ecx
xor    %eax,%eax
call   1030 <seatest_assert_string_equal@plt>
lea    0xe99(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x29,%ecx
xor    %eax,%eax
call   1030 <seatest_assert_string_equal@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_binary_extensions.buf = [2 x [20 x i8]] [[20 x i8] c"archive.tar.gz\00\00\00\00\00\00", [20 x i8] c"photos.tar.bz2\00\00\00\00\00\00"]
@.str = [7 x i8] c"tar.gz\00"
@__FUNCTION__.test_binary_extensions = [23 x i8] c"test_binary_extensions\00"
@.str.1 = [8 x i8] c"archive\00"
@.str.2 = [8 x i8] c"tar.bz2\00"
@.str.3 = [7 x i8] c"photos\00"
define void @test_binary_extensions() {
%1 = alloca [2 x [20 x i8]]
%2 = bitcast [2 x [20 x i8]]* %1 to i8*
br label %3
3: ; preds = %0
%4 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @cut_extension to i32 (i8*, ...)*)(i8* %5)
%7 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i32, i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 38)
br label %8
8: ; preds = %3
br label %9
9: ; preds = %8
%10 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%12 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 39)
br label %13
13: ; preds = %9
br label %14
14: ; preds = %13
%15 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 1
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @cut_extension to i32 (i8*, ...)*)(i8* %16)
%18 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i32, i8*, i32, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 40)
br label %19
19: ; preds = %14
br label %20
20: ; preds = %19
%21 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 1
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%23 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 41)
br label %24
24: ; preds = %20
ret void
}

LLVM IR (-O2):
@__const.test_binary_extensions.buf = [2 x [20 x i8]] [[20 x i8] c"archive.tar.gz\00\00\00\00\00\00", [20 x i8] c"photos.tar.bz2\00\00\00\00\00\00"]
@.str = [7 x i8] c"tar.gz\00"
@__FUNCTION__.test_binary_extensions = [23 x i8] c"test_binary_extensions\00"
@.str.1 = [8 x i8] c"archive\00"
@.str.2 = [8 x i8] c"tar.bz2\00"
@.str.3 = [7 x i8] c"photos\00"
define void @test_binary_extensions() {
%1 = alloca [2 x [20 x i8]]
%2 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 0, i64 0
%3 = call i32 (i8*, ...) bitcast (i32 (...)* @cut_extension to i32 (i8*, ...)*)(i8* %2)
%4 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i32, i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 38)
%5 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 39)
%6 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* %1, i64 0, i64 1, i64 0
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @cut_extension to i32 (i8*, ...)*)(i8* %6)
%8 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i32, i8*, i32, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 40)
%9 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__FUNCTION__.test_binary_extensions, i64 0, i64 0), i32 41)
ret void
}