#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 {
  int dummy;
};

/* Variables and functions */
struct node *append(struct node *, struct node *, int);
struct node *push(struct node *, int);
int rand();
void random_add(struct node **head, struct node **tail, int x) {
  int add;
  add = rand() % 99;
  if (*head == NULL) {
    *head = push(*head, x);
    *tail = *head;
  } else {
    *tail = append(*head, *tail, add);
  }
}


x86 assembly (clang, -O0):
<random_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x63,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    118f <random_add+0x5f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1040 <push@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11af <random_add+0x7f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
call   1030 <append@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_add>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <rand@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1174 <random_add+0x44>
movslq %eax,%rdx
imul   $0xffffffffa57eb503,%rdx,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x6,%eax
add    %ecx,%eax
imul   $0x63,%eax,%eax
sub    %eax,%edx
mov    (%r14),%rsi
call   1030 <append@plt>
jmp    1180 <random_add+0x50>
xor    %edi,%edi
mov    %ebp,%esi
call   1040 <push@plt>
mov    %rax,(%rbx)
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define void @random_add(%struct.node** %0, %struct.node** %1, i32 %2) {
%4 = alloca %struct.node**
%5 = alloca %struct.node**
%6 = alloca i32
%7 = alloca i32
store %struct.node** %0, %struct.node*** %4
store %struct.node** %1, %struct.node*** %5
store i32 %2, i32* %6
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 99
store i32 %9, i32* %7
%10 = load %struct.node**, %struct.node*** %4
%11 = load %struct.node*, %struct.node** %10
%12 = icmp eq %struct.node* %11, null
br i1 %12, label %13, label %22
13: ; preds = %3
%14 = load %struct.node**, %struct.node*** %4
%15 = load %struct.node*, %struct.node** %14
%16 = load i32, i32* %6
%17 = call %struct.node* @push(%struct.node* %15, i32 %16)
%18 = load %struct.node**, %struct.node*** %4
store %struct.node* %17, %struct.node** %18
%19 = load %struct.node**, %struct.node*** %4
%20 = load %struct.node*, %struct.node** %19
%21 = load %struct.node**, %struct.node*** %5
store %struct.node* %20, %struct.node** %21
br label %30
22: ; preds = %3
%23 = load %struct.node**, %struct.node*** %4
%24 = load %struct.node*, %struct.node** %23
%25 = load %struct.node**, %struct.node*** %5
%26 = load %struct.node*, %struct.node** %25
%27 = load i32, i32* %7
%28 = call %struct.node* @append(%struct.node* %24, %struct.node* %26, i32 %27)
%29 = load %struct.node**, %struct.node*** %5
store %struct.node* %28, %struct.node** %29
br label %30
30: ; preds = %22, %13
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
define void @random_add(%struct.node** nocapture %0, %struct.node** nocapture %1, i32 %2) {
%4 = tail call i32 (...) @rand()
%5 = load %struct.node*, %struct.node** %0
%6 = icmp eq %struct.node* %5, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call %struct.node* @push(%struct.node* null, i32 %2)
store %struct.node* %8, %struct.node** %0
br label %13
9: ; preds = %3
%10 = srem i32 %4, 99
%11 = load %struct.node*, %struct.node** %1
%12 = tail call %struct.node* @append(%struct.node* %5, %struct.node* %11, i32 %10)
br label %13
13: ; preds = %9, %7
%14 = phi %struct.node* [ %12, %9 ], [ %8, %7 ]
store %struct.node* %14, %struct.node** %1
ret void
}