#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 */

/* Variables and functions */
int lookup_set(char *);
int named_set(char *, int);
int /*<<< orphan*/ set_error1(char *);
int /*<<< orphan*/ set_intersection(int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void handle_intersection(char *setname1, char *setname2, char *setname3) {
  int set1, set2, set3;
  char message[255];
  set1 = lookup_set(setname1);
  if (set1 == 0) {
    set1 = named_set(setname1, 6);
    if (set1 == 0) {
      return;
    }
  }
  set2 = lookup_set(setname2);
  if (set2 == 0) {
    sprintf(message, "invalid setname(%s) in *", setname2);
    set_error1(message);
    return;
  }
  set3 = lookup_set(setname3);
  if (set3 == 0) {
    sprintf(message, "invalid setname(%s) in *", setname3);
    set_error1(message);
    return;
  }
  set_intersection(set2, set3, set1);
}


x86 assembly (clang, -O0):
<handle_intersection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <lookup_set@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11a2 <handle_intersection+0x52>
mov    -0x8(%rbp),%rdi
mov    $0x6,%esi
call   1040 <named_set@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    119d <handle_intersection+0x4d>
jmp    122c <handle_intersection+0xdc>
jmp    11a2 <handle_intersection+0x52>
mov    -0x10(%rbp),%rdi
call   1030 <lookup_set@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11e0 <handle_intersection+0x90>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe36(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1060 <set_error1@plt>
jmp    122c <handle_intersection+0xdc>
mov    -0x18(%rbp),%rdi
call   1030 <lookup_set@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    121e <handle_intersection+0xce>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdf8(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1060 <set_error1@plt>
jmp    122c <handle_intersection+0xdc>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <set_intersection@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_intersection>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <lookup_set@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1184 <handle_intersection+0x34>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <named_set@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11e5 <handle_intersection+0x95>
mov    %r15,%rdi
call   1030 <lookup_set@plt>
test   %eax,%eax
je     11b6 <handle_intersection+0x66>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <lookup_set@plt>
test   %eax,%eax
je     11c8 <handle_intersection+0x78>
mov    %ebx,%edi
mov    %eax,%esi
mov    %ebp,%edx
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <set_intersection@plt>
lea    0xe43(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
jmp    11d8 <handle_intersection+0x88>
lea    0xe31(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <set_error1@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"invalid setname(%s) in *\00"
define void @handle_intersection(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [255 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%11 = load i8*, i8** %4
%12 = call i32 @lookup_set(i8* %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = call i32 @named_set(i8* %16, i32 6)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %49
21: ; preds = %15
br label %22
22: ; preds = %21, %3
%23 = load i8*, i8** %5
%24 = call i32 @lookup_set(i8* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%32 = call i32 @set_error1(i8* %31)
br label %49
33: ; preds = %22
%34 = load i8*, i8** %6
%35 = call i32 @lookup_set(i8* %34)
store i32 %35, i32* %9
%36 = load i32, i32* %9
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%40 = load i8*, i8** %6
%41 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%43 = call i32 @set_error1(i8* %42)
br label %49
44: ; preds = %33
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = load i32, i32* %7
%48 = call i32 @set_intersection(i32 %45, i32 %46, i32 %47)
br label %49
49: ; preds = %44, %38, %27, %20
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"invalid setname(%s) in *\00"
define void @handle_intersection(i8* %0, i8* %1, i8* %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @lookup_set(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @named_set(i8* %0, i32 6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8, %3
%12 = phi i32 [ %9, %8 ], [ %6, %3 ]
%13 = tail call i32 @lookup_set(i8* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1)
%17 = call i32 @set_error1(i8* %5)
br label %26
18: ; preds = %11
%19 = tail call i32 @lookup_set(i8* %2)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %2)
%23 = call i32 @set_error1(i8* %5)
br label %26
24: ; preds = %18
%25 = tail call i32 @set_intersection(i32 %13, i32 %19, i32 %12)
br label %26
26: ; preds = %8, %24, %21, %15
ret void
}