#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 */
struct node_info {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ slist_add_tail(struct node_info *, int);
scalar_t__ slist_del(struct node_info *, int);
int /*<<< orphan*/ slist_for_each(struct node_info *);
struct node_info *slist_init();
int /*<<< orphan*/ slist_invert(struct node_info *);
int /*<<< orphan*/ stderr;
int main() {
  struct node_info *phead = slist_init();
  int i;
  for (i = 0; i < 10; ++i) {
    slist_add_tail(phead, i);
  }
  if (slist_del(phead, 5) < 0) {
    fprintf(stderr, "slist_del failed\n");
    exit(1);
  }
  slist_invert(phead);
  slist_for_each(phead);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <slist_init@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11c5 <main+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <slist_add_tail@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <main+0x21>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1030 <slist_del@plt>
cmp    $0x0,%rax
jge    11fc <main+0x7c>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1040 <slist_invert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <slist_for_each@plt>
lea    0xdfb(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1090 <slist_init@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1070 <slist_add_tail@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <slist_del@plt>
test   %rax,%rax
js     123a <main+0xba>
mov    %rbx,%rdi
call   1050 <slist_invert@plt>
mov    %rbx,%rdi
call   1060 <slist_for_each@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.node_info = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"slist_del failed\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node_info*
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.node_info* (...) @slist_init()
store %struct.node_info* %4, %struct.node_info** %2
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load %struct.node_info*, %struct.node_info** %2
%10 = load i32, i32* %3
%11 = call i32 @slist_add_tail(%struct.node_info* %9, i32 %10)
br label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = load %struct.node_info*, %struct.node_info** %2
%17 = call i64 @slist_del(%struct.node_info* %16, i32 5)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %15
%24 = load %struct.node_info*, %struct.node_info** %2
%25 = call i32 @slist_invert(%struct.node_info* %24)
%26 = load %struct.node_info*, %struct.node_info** %2
%27 = call i32 @slist_for_each(%struct.node_info* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.node_info = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"slist_del failed\0A\00"
define i32 @main() {
%1 = tail call %struct.node_info* (...) @slist_init()
%2 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 0)
%3 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 1)
%4 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 2)
%5 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 3)
%6 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 4)
%7 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 5)
%8 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 6)
%9 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 7)
%10 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 8)
%11 = tail call i32 @slist_add_tail(%struct.node_info* %1, i32 9)
%12 = tail call i64 @slist_del(%struct.node_info* %1, i32 5)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %0
%19 = tail call i32 @slist_invert(%struct.node_info* %1)
%20 = tail call i32 @slist_for_each(%struct.node_info* %1)
%21 = tail call i32 @putchar(i32 10)
ret i32 0
}