#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 */
typedef int /*<<< orphan*/ girls;
typedef int /*<<< orphan*/ boys;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, ...);
void bad_thing(int thrid, int children, int teachers) {
  int thing, sex;
  int namecnt, nameidx;
  char *name, *p;
  char buf[1024];
  char *things[] = {
      "Little %s put %s finger in the wall outlet and got electrocuted!",
      "Little %s fell off the slide and broke %s head!",
      "Little %s was playing with matches and lit %s hair on fire!",
      "Little %s drank a bottle of acid with %s lunch!",
      "Little %s caught %s hand in the paper shredder!",
      "Little %s wrestled with a stray dog and it bit %s finger off!"};
  char *boys[] = {"George", "John",     "Nick",  "Jim",   "Constantine",
                  "Chris",  "Peter",    "Paul",  "Steve", "Billy",
                  "Mike",   "Vangelis", "Antony"};
  char *girls[] = {"Maria",  "Irene",  "Christina", "Helena", "Georgia",
                   "Olga",   "Sophie", "Joanna",    "Zoe",    "Catherine",
                   "Marina", "Stella", "Vicky",     "Jenny"};
  thing = rand() % 4;
  sex = rand() % 2;
  namecnt =
      sex ? sizeof(boys) / sizeof(boys[0]) : sizeof(girls) / sizeof(girls[0]);
  nameidx = rand() % namecnt;
  name = sex ? boys[nameidx] : girls[nameidx];
  p = buf;
  p += sprintf(p, "*** Thread %d: Oh no! ", thrid);
  p += sprintf(p, things[thing], name, sex ? "his" : "her");
  p += sprintf(p, "\n*** Why were there only %d teachers for %d children?!\n",
               teachers, children);
  printf("%s", buf);
}


x86 assembly (clang, -O0):
<bad_thing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x550,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x460(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xe82(%rip),%rax
mov    %rax,-0x460(%rbp)
lea    0xeb5(%rip),%rax
mov    %rax,-0x458(%rbp)
lea    0xed7(%rip),%rax
mov    %rax,-0x450(%rbp)
lea    0xf05(%rip),%rax
mov    %rax,-0x448(%rbp)
lea    0xf27(%rip),%rax
mov    %rax,-0x440(%rbp)
lea    0xf49(%rip),%rax
mov    %rax,-0x438(%rbp)
lea    -0x4d0(%rbp),%rdi
lea    0x2b67(%rip),%rsi
mov    $0x68,%edx
call   1050 <memcpy@plt>
lea    -0x540(%rbp),%rdi
lea    0x2bbf(%rip),%rsi
mov    $0x70,%edx
call   1050 <memcpy@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edx
mov    $0xe,%eax
mov    $0xd,%ecx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1266 <bad_thing+0x116>
movslq -0x1c(%rbp),%rax
mov    -0x4d0(%rbp,%rax,8),%rax
ff
mov    %rax,-0x548(%rbp)
jmp    1279 <bad_thing+0x129>
movslq -0x1c(%rbp),%rax
mov    -0x540(%rbp,%rax,8),%rax
ff
mov    %rax,-0x548(%rbp)
mov    -0x548(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xf61(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
movslq -0x10(%rbp),%rax
mov    -0x460(%rbp,%rax,8),%rsi
ff
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%r8d
lea    0xf46(%rip),%rcx
lea    0xf3b(%rip),%rax
cmp    $0x0,%r8d
cmovne %rax,%rcx
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xf13(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
lea    -0x430(%rbp),%rsi
lea    0xf26(%rip),%rdi
call   1030 <printf@plt>
add    $0x550,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad_thing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %edx,0x8(%rsp)
mov    %esi,0xc(%rsp)
mov    %edi,0x4(%rsp)
lea    0xeac(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xee1(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xf05(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xf35(%rip),%rax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
and    $0x1,%ebx
mov    $0xe,%ebp
sub    %ebx,%ebp
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebp
test   %ebx,%ebx
movslq %edx,%rax
lea    0x2c00(%rip),%rcx
lea    (%rcx,%rax,8),%rcx
lea    0x2b85(%rip),%rdx
lea    (%rdx,%rax,8),%rax
lea    0xfe5(%rip),%rdx
lea    0xfda(%rip),%r15
cmove  %rdx,%r15
cmove  %rcx,%rax
mov    (%rax),%r14
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r12d
lea    0xf9f(%rip),%rsi
lea    0x40(%rsp),%r13
mov    %r13,%rdi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
cltq
lea    (%rsp,%rax,1),%rbx
add    $0x40,%rbx
movslq %r12d,%rax
mov    0x10(%rsp,%rax,8),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
movslq %eax,%rdi
add    %rbx,%rdi
lea    0xf7c(%rip),%rsi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xf9e(%rip),%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Little %s put %s finger in the wall outlet and got electrocuted!\00"
@.str.1 = [48 x i8] c"Little %s fell off the slide and broke %s head!\00"
@.str.2 = [60 x i8] c"Little %s was playing with matches and lit %s hair on fire!\00"
@.str.3 = [48 x i8] c"Little %s drank a bottle of acid with %s lunch!\00"
@.str.4 = [48 x i8] c"Little %s caught %s hand in the paper shredder!\00"
@.str.5 = [62 x i8] c"Little %s wrestled with a stray dog and it bit %s finger off!\00"
@.str.6 = [7 x i8] c"George\00"
@.str.7 = [5 x i8] c"John\00"
@.str.8 = [5 x i8] c"Nick\00"
@.str.9 = [4 x i8] c"Jim\00"
@.str.10 = [12 x i8] c"Constantine\00"
@.str.11 = [6 x i8] c"Chris\00"
@.str.12 = [6 x i8] c"Peter\00"
@.str.13 = [5 x i8] c"Paul\00"
@.str.14 = [6 x i8] c"Steve\00"
@.str.15 = [6 x i8] c"Billy\00"
@.str.16 = [5 x i8] c"Mike\00"
@.str.17 = [9 x i8] c"Vangelis\00"
@.str.18 = [7 x i8] c"Antony\00"
@__const.bad_thing.boys = [13 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i32 0, i32 0)]
@.str.19 = [6 x i8] c"Maria\00"
@.str.20 = [6 x i8] c"Irene\00"
@.str.21 = [10 x i8] c"Christina\00"
@.str.22 = [7 x i8] c"Helena\00"
@.str.23 = [8 x i8] c"Georgia\00"
@.str.24 = [5 x i8] c"Olga\00"
@.str.25 = [7 x i8] c"Sophie\00"
@.str.26 = [7 x i8] c"Joanna\00"
@.str.27 = [4 x i8] c"Zoe\00"
@.str.28 = [10 x i8] c"Catherine\00"
@.str.29 = [7 x i8] c"Marina\00"
@.str.30 = [7 x i8] c"Stella\00"
@.str.31 = [6 x i8] c"Vicky\00"
@.str.32 = [6 x i8] c"Jenny\00"
@__const.bad_thing.girls = [14 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.32, i32 0, i32 0)]
@.str.33 = [23 x i8] c"*** Thread %d: Oh no! \00"
@.str.34 = [4 x i8] c"his\00"
@.str.35 = [4 x i8] c"her\00"
@.str.36 = [56 x i8] c"\0A*** Why were there only %d teachers for %d children?!\0A\00"
@.str.37 = [3 x i8] c"%s\00"
define void @bad_thing(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [1024 x i8]
%14 = alloca [6 x i8*]
%15 = alloca [13 x i8*]
%16 = alloca [14 x i8*]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%17 = bitcast [6 x i8*]* %14 to i8*
%18 = bitcast i8* %17 to [6 x i8*]*
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 0
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 1
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 2
store i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 3
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 4
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 5
store i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i32 0, i32 0), i8** %24
%25 = bitcast [13 x i8*]* %15 to i8*
%26 = bitcast [14 x i8*]* %16 to i8*
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 4
store i32 %28, i32* %7
%29 = call i32 (...) @rand()
%30 = srem i32 %29, 2
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i64 13, i64 14
%35 = trunc i64 %34 to i32
store i32 %35, i32* %9
%36 = call i32 (...) @rand()
%37 = load i32, i32* %9
%38 = srem i32 %36, %37
store i32 %38, i32* %10
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %3
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [13 x i8*], [13 x i8*]* %15, i64 0, i64 %43
%45 = load i8*, i8** %44
br label %51
46: ; preds = %3
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [14 x i8*], [14 x i8*]* %16, i64 0, i64 %48
%50 = load i8*, i8** %49
br label %51
51: ; preds = %46, %41
%52 = phi i8* [ %45, %41 ], [ %50, %46 ]
store i8* %52, i8** %11
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
store i8* %53, i8** %12
%54 = load i8*, i8** %12
%55 = load i32, i32* %4
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.33, i64 0, i64 0), i32 %55)
%57 = load i8*, i8** %12
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds i8, i8* %57, i64 %58
store i8* %59, i8** %12
%60 = load i8*, i8** %12
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [6 x i8*], [6 x i8*]* %14, i64 0, i64 %62
%64 = load i8*, i8** %63
%65 = load i8*, i8** %11
%66 = load i32, i32* %8
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.34, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.35, i64 0, i64 0)
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* %64, i8* %65, i8* %69)
%71 = load i8*, i8** %12
%72 = sext i32 %70 to i64
%73 = getelementptr inbounds i8, i8* %71, i64 %72
store i8* %73, i8** %12
%74 = load i8*, i8** %12
%75 = load i32, i32* %6
%76 = load i32, i32* %5
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.36, i64 0, i64 0), i32 %75, i32 %76)
%78 = load i8*, i8** %12
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds i8, i8* %78, i64 %79
store i8* %80, i8** %12
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%82 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.37, i64 0, i64 0), i8* %81)
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"Little %s put %s finger in the wall outlet and got electrocuted!\00"
@.str.1 = [48 x i8] c"Little %s fell off the slide and broke %s head!\00"
@.str.2 = [60 x i8] c"Little %s was playing with matches and lit %s hair on fire!\00"
@.str.3 = [48 x i8] c"Little %s drank a bottle of acid with %s lunch!\00"
@.str.6 = [7 x i8] c"George\00"
@.str.7 = [5 x i8] c"John\00"
@.str.8 = [5 x i8] c"Nick\00"
@.str.9 = [4 x i8] c"Jim\00"
@.str.10 = [12 x i8] c"Constantine\00"
@.str.11 = [6 x i8] c"Chris\00"
@.str.12 = [6 x i8] c"Peter\00"
@.str.13 = [5 x i8] c"Paul\00"
@.str.14 = [6 x i8] c"Steve\00"
@.str.15 = [6 x i8] c"Billy\00"
@.str.16 = [5 x i8] c"Mike\00"
@.str.17 = [9 x i8] c"Vangelis\00"
@.str.18 = [7 x i8] c"Antony\00"
@__const.bad_thing.boys = [13 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i32 0, i32 0)]
@.str.19 = [6 x i8] c"Maria\00"
@.str.20 = [6 x i8] c"Irene\00"
@.str.21 = [10 x i8] c"Christina\00"
@.str.22 = [7 x i8] c"Helena\00"
@.str.23 = [8 x i8] c"Georgia\00"
@.str.24 = [5 x i8] c"Olga\00"
@.str.25 = [7 x i8] c"Sophie\00"
@.str.26 = [7 x i8] c"Joanna\00"
@.str.27 = [4 x i8] c"Zoe\00"
@.str.28 = [10 x i8] c"Catherine\00"
@.str.29 = [7 x i8] c"Marina\00"
@.str.30 = [7 x i8] c"Stella\00"
@.str.31 = [6 x i8] c"Vicky\00"
@.str.32 = [6 x i8] c"Jenny\00"
@__const.bad_thing.girls = [14 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.32, i32 0, i32 0)]
@.str.33 = [23 x i8] c"*** Thread %d: Oh no! \00"
@.str.34 = [4 x i8] c"his\00"
@.str.35 = [4 x i8] c"her\00"
@.str.36 = [56 x i8] c"\0A*** Why were there only %d teachers for %d children?!\0A\00"
@.str.37 = [3 x i8] c"%s\00"
define void @bad_thing(i32 %0, i32 %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca [6 x i8*]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast [6 x i8*]* %5 to i8*
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 2
store i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 3
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = tail call i32 (...) @rand()
%13 = tail call i32 (...) @rand()
%14 = and i32 %13, 1
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 14, i32 13
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, %16
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [14 x i8*], [14 x i8*]* @__const.bad_thing.girls, i64 0, i64 %19
%21 = getelementptr inbounds [13 x i8*], [13 x i8*]* @__const.bad_thing.boys, i64 0, i64 %19
%22 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.35, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.34, i64 0, i64 0)
%23 = select i1 %15, i8** %20, i8** %21
%24 = load i8*, i8** %23
%25 = srem i32 %12, 4
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.33, i64 0, i64 0), i32 %0)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %27
%29 = sext i32 %25 to i64
%30 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* dereferenceable(1) %31, i8* %24, i8* %22)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %28, i64 %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.36, i64 0, i64 0), i32 %2, i32 %1)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.37, i64 0, i64 0), i8* %6)
ret void
}