void task0() {
  __asm__("movl $0x17,%%eax\n\t"
          "mov  %%ax,%%ds\n\t"
          "mov  %%ax,%%es\n\t"
          "mov  %%ax,%%fs\n\t"
          "mov  %%ax,%%gs" ::);
  int int_num = 0;
  int tmp;
  __asm__("int $0x80" : "=a"(tmp) : "a"(int_num));
  if (tmp == 0) {
    exe("/binary/elf_child");
    print_XY('C', 0, 0);
    for (;;)
      ;
  } else if (tmp == -1) {
    print_XY('E', 0, 1);
    for (;;)
      ;
  } else {
    for (;;)
      ;
  }
}


x86 assembly (clang, -O0):
<task0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x17,%eax
mov    %eax,%ds
mov    %eax,%es
mov    %eax,%fs
mov    %eax,%gs
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
int    $0x80
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1171 <task0+0x51>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <exe@plt>
mov    $0x43,%edi
xor    %edx,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1040 <print_XY@plt>
jmp    116c <task0+0x4c>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1193 <task0+0x73>
mov    $0x45,%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <print_XY@plt>
jmp    118e <task0+0x6e>
jmp    1198 <task0+0x78>
jmp    1198 <task0+0x78>

x86 assembly (clang, -O2):
<task0>:
push   %rax
mov    $0x17,%eax
mov    %eax,%ds
mov    %eax,%es
mov    %eax,%fs
mov    %eax,%gs
xor    %eax,%eax
int    $0x80
cmp    $0xffffffff,%eax
je     1172 <task0+0x52>
test   %eax,%eax
jne    1170 <task0+0x50>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <exe@plt>
mov    $0x43,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <print_XY@plt>
nopl   0x0(%rax)
jmp    1160 <task0+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
jmp    1170 <task0+0x50>
mov    $0x45,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <print_XY@plt>
cs nopw 0x0(%rax,%rax,1)
nop
jmp    1190 <task0+0x70>

LLVM IR (-O0):
@.str = [18 x i8] c"/binary/elf_child\00"
define void @task0() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* %1
%4 = call i32 asm "int $$0x80", "={ax},{ax},~{dirflag},~{fpsr},~{flags}"(i32 %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @exe to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @print_XY to i32 (i32, i32, i32, ...)*)(i32 67, i32 0, i32 0)
br label %10
10: ; preds = %10, %7
br label %10
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @print_XY to i32 (i32, i32, i32, ...)*)(i32 69, i32 0, i32 1)
br label %16
16: ; preds = %16, %14
br label %16
17: ; preds = %11
br label %18
18: ; preds = %18, %17
br label %18
}

LLVM IR (-O2):
@.str = [18 x i8] c"/binary/elf_child\00"
define void @task0() {
tail call void asm sideeffect "movl $$0x17,%eax\0A\09mov %ax,%ds\0A\09mov %ax,%es\0A\09mov %ax,%fs\0A\09mov %ax,%gs", "~{dirflag},~{fpsr},~{flags}"()
%1 = tail call i32 asm "int $$0x80", "={ax},{ax},~{dirflag},~{fpsr},~{flags}"(i32 0)
switch i32 %1, label %9 [
i32 0, label %2
i32 -1, label %6
]
2: ; preds = %0
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @exe to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @print_XY to i32 (i32, i32, i32, ...)*)(i32 67, i32 0, i32 0)
br label %5
5: ; preds = %5, %2
br label %5
6: ; preds = %0
%7 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @print_XY to i32 (i32, i32, i32, ...)*)(i32 69, i32 0, i32 1)
br label %8
8: ; preds = %8, %6
br label %8
9: ; preds = %0, %9
br label %9
}