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

/* Variables and functions */
struct set_s *Insert(struct set_s *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
struct set_s *Read_set(struct set_s *a_p, int *asize, int listNumber) {
  if (listNumber == 1) {
    printf("Enter the elements of A.\n");
  } else {
    printf("Enter the elements of B.\n");
  }
  int i;
  scanf("%d", &i);
  while (i > -1) {
    (*asize)++;
    a_p = Insert(a_p, i);
    scanf("%d", &i);
  }
  return a_p;
}


x86 assembly (clang, -O0):
<Read_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    115e <Read_set+0x2e>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    116a <Read_set+0x3a>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jle    11b4 <Read_set+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <Insert@plt>
mov    %rax,-0x8(%rbp)
lea    0xe8e(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
jmp    117a <Read_set+0x4a>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_set>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    $0x1,%edx
lea    0xed4(%rip),%rax
lea    0xeb4(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     11a2 <Read_set+0x72>
lea    0xe88(%rip),%r15
lea    0x4(%rsp),%r12
nopl   (%rax)
addl   $0x1,(%r14)
mov    %rbx,%rdi
call   1040 <Insert@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jns    1180 <Read_set+0x50>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.set_s = type { i32 }
@.str = [26 x i8] c"Enter the elements of A.\0A\00"
@.str.1 = [26 x i8] c"Enter the elements of B.\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define %struct.set_s* @Read_set(%struct.set_s* %0, i32* %1, i32 %2) {
%4 = alloca %struct.set_s*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store %struct.set_s* %0, %struct.set_s** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %14
12: ; preds = %3
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
br label %16
16: ; preds = %19, %14
%17 = load i32, i32* %7
%18 = icmp sgt i32 %17, -1
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
%23 = load %struct.set_s*, %struct.set_s** %4
%24 = load i32, i32* %7
%25 = call %struct.set_s* @Insert(%struct.set_s* %23, i32 %24)
store %struct.set_s* %25, %struct.set_s** %4
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
br label %16
27: ; preds = %16
%28 = load %struct.set_s*, %struct.set_s** %4
ret %struct.set_s* %28
}

LLVM IR (-O2):
%struct.set_s = type { i32 }
@.str.2 = [3 x i8] c"%d\00"
@str = [25 x i8] c"Enter the elements of B.\00"
@str.3 = [25 x i8] c"Enter the elements of A.\00"
define %struct.set_s* @Read_set(%struct.set_s* %0, i32* nocapture %1, i32 %2) {
%4 = alloca i32
%5 = icmp eq i32 %2, 1
%6 = select i1 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %21
12: ; preds = %3, %12
%13 = phi i32 [ %19, %12 ], [ %10, %3 ]
%14 = phi %struct.set_s* [ %17, %12 ], [ %0, %3 ]
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
%17 = call %struct.set_s* @Insert(%struct.set_s* %14, i32 %13)
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, -1
br i1 %20, label %12, label %21
21: ; preds = %12, %3
%22 = phi %struct.set_s* [ %0, %3 ], [ %17, %12 ]
ret %struct.set_s* %22
}